package com.mission.schedule.fragment;

import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.app.Dialog;
import android.appwidget.AppWidgetManager;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent;
import android.content.res.AssetFileDescriptor;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.media.MediaPlayer;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v4.app.Fragment;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.text.Html;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.TranslateAnimation;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.android.volley.AuthFailureError;
import com.android.volley.DefaultRetryPolicy;
import com.android.volley.Request;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;
import com.mission.schedule.R;
import com.mission.schedule.activity.AddEverydayDetailTaskActivity;
import com.mission.schedule.activity.GuoQiWeiJieShuActivity;
import com.mission.schedule.activity.LingShengActivity;
import com.mission.schedule.activity.MainActivity;
import com.mission.schedule.activity.MyStateActivity;
import com.mission.schedule.activity.NewResiginActivity;
import com.mission.schedule.activity.NoteListActivity;
import com.mission.schedule.activity.PhoneCodeLoginActivity;
import com.mission.schedule.activity.SchZhuanFaActivity;
import com.mission.schedule.adapter.ImportantNoEndSchAdapter;
import com.mission.schedule.applcation.App;
import com.mission.schedule.bean.MySchBean;
import com.mission.schedule.bean.RepeatBean;
import com.mission.schedule.clock.QueryAlarmData;
import com.mission.schedule.constants.Const;
import com.mission.schedule.constants.ShareFile;
import com.mission.schedule.entity.CLRepeatTable;
import com.mission.schedule.entity.LocateAllNoticeTable;
import com.mission.schedule.entity.ScheduleTable;
import com.mission.schedule.my160920.FrendLyActivity;
import com.mission.schedule.my160920.NewSchZhuanFaActivity;
import com.mission.schedule.service.UpLoadService;
import com.mission.schedule.swipexlistview.SwipeXListViewNoHead;
import com.mission.schedule.utils.CalendarChange;
import com.mission.schedule.utils.CharacterUtil;
import com.mission.schedule.utils.DateUtil;
import com.mission.schedule.utils.InWeekUtils;
import com.mission.schedule.utils.MyLinearLayout;
import com.mission.schedule.utils.MyViewPager;
import com.mission.schedule.utils.NetUtil;
import com.mission.schedule.utils.NetUtil.NetWorkState;
import com.mission.schedule.utils.RepeatSetChildEndUtils;
import com.mission.schedule.utils.SchDateComparator;
import com.mission.schedule.utils.SharedPrefUtil;
import com.mission.schedule.utils.StringUtils;
import com.mission.schedule.utils.Utils;

import org.json.JSONException;
import org.json.JSONObject;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import cn.sharesdk.framework.ShareSDK;
import cn.sharesdk.onekeyshare.OnekeyShare;

@SuppressLint({ "HandlerLeak" })
public class ImportantNoEndSchFragment extends Fragment {

	private SwipeXListViewNoHead important_listview;

	List<Map<String, String>> mList = new ArrayList<Map<String, String>>();
	List<Map<String, String>> otherlist = new ArrayList<Map<String, String>>();
	List<Map<String, String>> yestodaylist = new ArrayList<Map<String, String>>();
	List<Map<String, String>> todaylist = new ArrayList<Map<String, String>>();
	List<Map<String, String>> tomorrowlist = new ArrayList<Map<String, String>>();
	List<Map<String, String>> inweeklist = new ArrayList<Map<String, String>>();
	List<Map<String, String>> outweeklist = new ArrayList<Map<String, String>>();

	ImportantNoEndSchAdapter adapter = null;
	Context context;
	App application = App.getDBcApplication();

	String time,userid;
	String ringdesc;
	String ringcode;

	SharedPrefUtil sharedPrefUtil = null;
	private boolean isShow;// 判断是否已经显示

	int width, heigth;
	// int scrolledX = 0;
	// int scrolledY = 0;
	InWeekUtils inWeekUtils = new InWeekUtils();
	RepeatSetChildEndUtils repeatSetChildEndUtils = new RepeatSetChildEndUtils();

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		return inflater.inflate(R.layout.fragment_importantsch, container,
				false);
	}

	@Override
	public void onHiddenChanged(boolean hidden) {
		super.onHiddenChanged(hidden);
		if (!hidden && !isShow) {
			isShow = true;
			init();
			loadData();
			setAdapter();
		}
	}

	private void init() {
		View view = getView();
		context = getActivity();
		important_listview = (SwipeXListViewNoHead) view
				.findViewById(R.id.important_listview);
		important_listview.setPullLoadEnable(false);
		sharedPrefUtil = new SharedPrefUtil(context, ShareFile.USERFILE);
		userid = sharedPrefUtil.getString(context, ShareFile.USERFILE,
				ShareFile.USERID, "");
		time = sharedPrefUtil.getString(context, ShareFile.USERFILE,
				ShareFile.ALLTIME, "08:58");
		ringdesc = sharedPrefUtil.getString(context, ShareFile.USERFILE,
				ShareFile.MUSICDESC, "完成任务");
		ringcode = sharedPrefUtil.getString(context, ShareFile.USERFILE,
				ShareFile.MUSICCODE, "g_88");

		View footView = LayoutInflater.from(context).inflate(
				R.layout.activity_alarmfriends_footview, null);
		important_listview.addFooterView(footView);
		/**
		 * 获取屏幕的高度和宽度
		 */
		DisplayMetrics metric = new DisplayMetrics();
		getActivity().getWindowManager().getDefaultDisplay().getMetrics(metric);
		width = metric.widthPixels;
		heigth = metric.heightPixels;
	}

	private void loadData() {
		try {
			// 1 两天以前 2 昨天 3今天 4明天 5一周以内 6一周以后
			otherlist.clear();
			yestodaylist.clear();
			todaylist.clear();
			tomorrowlist.clear();
			inweeklist.clear();
			outweeklist.clear();
			mList.clear();

			otherlist = application.queryAllSchData(31, 0, 0);
			yestodaylist = application.queryAllSchData(32, 0, 0);
			todaylist = application.queryAllSchData(33, 0, 0);
			tomorrowlist = application.queryAllSchData(34, 0, 0);
			inweeklist = application.queryAllSchData(35, 0, 0);
			outweeklist = application.queryAllSchData(36, 0, 0);

			Collections.sort(otherlist, new SchDateComparator());

			mList.addAll(otherlist);
			mList.addAll(yestodaylist);
			mList.addAll(todaylist);
			mList.addAll(tomorrowlist);
			mList.addAll(inweeklist);
			mList.addAll(outweeklist);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	protected void setAdapter() {
		adapter = new ImportantNoEndSchAdapter(context, mList,
				R.layout.adapter_important, handler, important_listview, width);
		important_listview.setPullLoadEnable(false);
		important_listview.setPullRefreshEnable(false);
		important_listview.setAdapter(adapter);
	}

	private void RefreshMyData() {
		new Thread(new Runnable() {

			@Override
			public void run() {
				if (NetUtil.getConnectState(getActivity()) != NetWorkState.NONE) {
					Intent intent = new Intent(getActivity(),
							UpLoadService.class);
					intent.setAction(Const.SHUAXINDATA);
					intent.setPackage(getActivity().getPackageName());
					getActivity().startService(intent);
				} else {
					return;
				}
			}
		}).start();
	}

	private void UpLoadData() {
		if (NetUtil.getConnectState(getActivity()) != NetWorkState.NONE) {
			Intent intent = new Intent(getActivity(), UpLoadService.class);
			intent.setAction(Const.UPLOADDATA);
			intent.setPackage(getActivity().getPackageName());
			getActivity().startService(intent);
		} else {
			return;
		}
	}

	/**
	 * app日程同步下行修改好友信息和留言
	 */
	public void updateFrendsPostState(final String cid) {

		StringRequest stringRequest = new StringRequest(Request.Method.POST, "http://121.40.19.103/timetable/appFrends_updateFrendsPostState.do",
				new Response.Listener<String>() {
					@Override
					public void onResponse(String result) {
						if (!TextUtils.isEmpty(result)) {
							try {
								if (responseCode(result)){
									//TODO  同步成功
								}else {
//                                    updateFrendsPostState(cid);
								}
							} catch (Exception e) {
								e.printStackTrace();
							}
						}
					}

				}, new Response.ErrorListener() {
			@Override
			public void onErrorResponse(VolleyError volleyError) {
				Log.d("TAG", "error:" + volleyError.toString());
			}
		}) {
			@Override
			protected Map<String, String> getParams() throws AuthFailureError {
				Map<String, String> map = new HashMap<>();
				map.put("uId", userid);
				map.put("cId", cid);
				return map;
			}
		};
		stringRequest.setTag("findLyNewNum");
		stringRequest.setRetryPolicy(new DefaultRetryPolicy(100000, 1, 1.0f));
		App.queues.add(stringRequest);
	}

	public boolean responseCode(String response) throws JSONException {
		int status = 0;
		JSONObject jsonObject = new JSONObject(response);
		int msg = jsonObject.getInt("status");
		return status == msg;
	}

	private Handler handler = new Handler() {

		@SuppressWarnings("unchecked")
		@Override
		public void handleMessage(Message msg) {
			super.handleMessage(msg);
			Map<String, String> mMap = (Map<String, String>) msg.obj;
			// Map upMap = null;
			// String value = "0";
			int position = msg.arg1;
			switch (msg.what) {
			case 0:// 点击菜单(详情菜单)
				if (Integer.valueOf(mList.get(position).get(ScheduleTable.schcRecommendId)) > 0
						&& Integer.valueOf(mList.get(position).get(ScheduleTable.schAID)) == 0){
					if (!mList.get(position).get(ScheduleTable.schRepeatID).equals("0")){
						dialogDetailOnClick(mMap, position);
					} else {
						updateFrendsPostState(mList.get(position).get(ScheduleTable.schID));
						Intent intent1 = new Intent(getActivity(), FrendLyActivity.class);
						intent1.putExtra("types", 1);

						MySchBean mySchBean = new MySchBean();
						mySchBean.schID = mMap.get(ScheduleTable.schID);
						mySchBean.schContent = mMap.get(ScheduleTable.schContent);
						mySchBean.schDate = mMap.get(ScheduleTable.schDate);
						mySchBean.schTime = mMap.get(ScheduleTable.schTime);
						mySchBean.schIsAlarm = mMap.get(ScheduleTable.schIsAlarm);
						mySchBean.schBeforeTime = mMap.get(ScheduleTable.schBeforeTime);
						mySchBean.schDisplayTime = mMap.get(ScheduleTable.schDisplayTime);
						mySchBean.schIsPostpone = mMap.get(ScheduleTable.schIsPostpone);
						mySchBean.schIsImportant = mMap.get(ScheduleTable.schIsImportant);
						mySchBean.schColorType = mMap.get(ScheduleTable.schColorType);
						mySchBean.schIsEnd = mMap.get(ScheduleTable.schIsEnd);
						mySchBean.schCreateTime = mMap.get(ScheduleTable.schCreateTime);
						mySchBean.schTags = mMap.get(ScheduleTable.schTags);
						mySchBean.schSourceType = mMap.get(ScheduleTable.schSourceType);
						mySchBean.schSourceDesc = mMap.get(ScheduleTable.schSourceDesc);
						mySchBean.schSourceDescSpare = mMap
								.get(ScheduleTable.schSourceDescSpare);
						mySchBean.schRepeatID = mMap.get(ScheduleTable.schRepeatID);
						mySchBean.schRepeatDate = mMap.get(ScheduleTable.schRepeatDate);
						mySchBean.schUpdateTime = mMap.get(ScheduleTable.schUpdateTime);
						mySchBean.schUpdateState = mMap.get(ScheduleTable.schUpdateState);
						mySchBean.schOpenState = mMap.get(ScheduleTable.schOpenState);
						mySchBean.schRepeatLink = mMap.get(ScheduleTable.schRepeatLink);
						mySchBean.schRingDesc = mMap.get(ScheduleTable.schRingDesc);
						mySchBean.schRingCode = mMap.get(ScheduleTable.schRingCode);
						mySchBean.schcRecommendName = mMap
								.get(ScheduleTable.schcRecommendName);
						mySchBean.schRead = mMap.get(ScheduleTable.schRead);
						intent1.putExtra("bean", mySchBean);
						intent1.putExtra("schFriendID", mMap.get(ScheduleTable.schcRecommendId));
						startActivity(intent1);
					}
				}else {
					dialogDetailOnClick(mMap, position);
				}
				break;

			case 2:// 设为结束
					// updateSchedule(mMap, ScheduleTable.schIsEnd,
					// ScheduleTable.schUpdateState);
					// App.getDBcApplication().updateSchReadData(
					// Integer.parseInt(mMap.get(ScheduleTable.schID)), 0);
					// App.getDBcApplication().updateSchRepeatLinkData(
					// Integer.parseInt(mMap.get(ScheduleTable.schID)), 3);
					// updateSchClock(mMap, LocateAllNoticeTable.isEnd);
					// loadData();
					// adapter.notifyDataSetChanged();
				if ("0".equals(mMap.get(ScheduleTable.schRepeatID))) {
					// updateScheduleRead1(mMap, ScheduleTable.schRead);
				} else {
					updateScheduleRead2(mMap, ScheduleTable.schRead,
							ScheduleTable.schRepeatLink);
				}
				updateFocusStateSch(mMap, ScheduleTable.schFocusState);
				updateScheduleIsEnd(mMap, ScheduleTable.schIsEnd,
						ScheduleTable.schUpdateState);
				updateSchClock(mMap, LocateAllNoticeTable.isEnd);
				adapter.notifyDataSetChanged();
				sharedPrefUtil.putString(context, ShareFile.USERFILE,
						ShareFile.ENDUPDATETIME,
						DateUtil.formatDateTimeSs(new Date()));
				final String updatetime = sharedPrefUtil.getString(context,
						ShareFile.USERFILE, ShareFile.ENDUPDATETIME,
						DateUtil.formatDateTimeSs(new Date()));
				handler.postDelayed(new Runnable() {
					@Override
					public void run() {
						String delaytime = DateUtil
								.formatDateTimeSs(new Date());
						if (DateUtil.parseDateTimeSs(delaytime).getTime()
								- DateUtil.parseDateTimeSs(updatetime)
										.getTime() >= 3000) {
							UpLoadData();
						}
					}
				}, 3000);
				if (DateUtil.parseDateTime(DateUtil.formatDateTime(new Date()))
						.getTime() >= DateUtil.parseDateTime(
						mMap.get(ScheduleTable.schDate) + " "
								+ mMap.get(ScheduleTable.schTime)).getTime()) {
					QueryAlarmData.writeAlarm(getActivity()
							.getApplicationContext());

				}
				break;

			case 3:// 删除
				alertDeleteDialog(mMap, 0, position);
				break;
			}
		}

	};

	private void updateScheduleRead(Map<String, String> mMap, String key,
			String key1) {
		try {
			String value = "0";
			Map<String, String> upMap = new HashMap<String, String>();
			important_listview.hiddenRight();
			if ("0".equals(mMap.get(key)))
				value = "0";
			else
				value = "0";
			upMap.put(key, value);
			upMap.put(key1, "3");
			App.getDBcApplication().updateScheduleData(upMap,
					"where schID=" + mMap.get("schID"));
			mMap.put(key, value);
		} catch (NumberFormatException e) {
			e.printStackTrace();
		}
	}

	private void updateScheduleRead2(Map<String, String> mMap, String key,
			String key1) {
		try {
			String value = "0";
			Map<String, String> upMap = new HashMap<String, String>();
			important_listview.hiddenRight();
			// if ("0".equals(mMap.get(key)))
			// value = "0";
			// else
			value = mMap.get(key);
			upMap.put(key, value);
			upMap.put(key1, "3");
			App.getDBcApplication().updateScheduleData(upMap,
					"where schID=" + mMap.get("schID"));
			mMap.put(key, value);
			mMap.put(key1, "3");
		} catch (NumberFormatException e) {
			e.printStackTrace();
		}
	}

	private void updateScheduleRead1(Map<String, String> mMap, String key) {
		try {
			String value = "0";
			Map<String, String> upMap = new HashMap<String, String>();
			important_listview.hiddenRight();
			if ("0".equals(mMap.get(key)))
				value = "0";
			else
				value = "1";
			upMap.put(key, value);
			App.getDBcApplication().updateScheduleData1(upMap,
					"where schID=" + mMap.get("schID"));
			mMap.put(key, value);
		} catch (NumberFormatException e) {
			e.printStackTrace();
		}
	}

	private void alertDeleteDialog(final Map<String, String> mMap,
			final int type, final int position) {
		final AlertDialog builder = new AlertDialog.Builder(context).create();
		builder.show();
		Window window = builder.getWindow();
		android.view.WindowManager.LayoutParams params = window.getAttributes();// 获取LayoutParams
		params.alpha = 0.92f;
		window.setAttributes(params);// 设置生效
		window.setContentView(R.layout.dialog_alterdelete);
		TextView delete_ok = (TextView) window.findViewById(R.id.delete_ok);
		delete_ok.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				builder.cancel();
				if (type == 0) {
					App.getDBcApplication().updateSchReadData(
							Integer.parseInt(mMap.get(ScheduleTable.schID)), 0);
					App.getDBcApplication().updateSchRepeatLinkData(
							Integer.parseInt(mMap.get(ScheduleTable.schID)), 2);
					String deleteId = mMap.get(ScheduleTable.schID);
					App dbContextExtended = App.getDBcApplication();
					dbContextExtended.deleteScheduleLocalData(deleteId);
					dbContextExtended.deleteSch(Integer.parseInt(deleteId));
					important_listview.hiddenRight();
					App.getDBcApplication().updateSchReadData(
							Integer.parseInt(mMap.get(ScheduleTable.schID)), 0);
					if ("1".equals(mMap.get(ScheduleTable.schRepeatLink))
							|| "3".equals(mMap.get(ScheduleTable.schRepeatLink))) {
						Map<String, String> map = App
								.getDBcApplication()
								.QueryStateData(
										Integer.parseInt(mMap
												.get(ScheduleTable.schRepeatID)));
						if (map != null) {
							String lastdate = StringUtils.getIsStringEqulesNull(map
									.get(CLRepeatTable.repDateOne));
							String nextdate = StringUtils.getIsStringEqulesNull(map
									.get(CLRepeatTable.repDateTwo));
							String repdate = mMap
									.get(ScheduleTable.schRepeatDate);
							if (repdate.equals(lastdate) || repdate.equals(nextdate)) {
								if (!"".equals(lastdate)&& lastdate.equals(repdate)) {
									application
											.updateSchCLRepeatData(
													Integer.parseInt(mMap
															.get(ScheduleTable.schRepeatID)),
													mMap.get(ScheduleTable.schRepeatDate),
													map.get(CLRepeatTable.repDateTwo),
													2,
													Integer.parseInt(map
															.get(CLRepeatTable.repStateTwo)));
								} else if (!"".equals(nextdate)&& nextdate.equals(repdate)) {
									application
											.updateSchCLRepeatData(
													Integer.parseInt(mMap
															.get(ScheduleTable.schRepeatID)),
													map.get(CLRepeatTable.repDateOne),
													mMap.get(ScheduleTable.schRepeatDate),
													Integer.parseInt(map
															.get(CLRepeatTable.repStateOne)),
													2);
								}
							} else {
								if ("".equals(lastdate) && "".equals(nextdate)) {
									application
											.updateSchCLRepeatData(
													Integer.parseInt(mMap
															.get(ScheduleTable.schRepeatID)),
													mMap.get(ScheduleTable.schRepeatDate),
													map.get(CLRepeatTable.repDateTwo),
													2,
													Integer.parseInt(map
															.get(CLRepeatTable.repStateTwo)));
								} else if ("".equals(lastdate) && !"".equals(nextdate)) {
									application
											.updateSchCLRepeatData(
													Integer.parseInt(mMap
															.get(ScheduleTable.schRepeatID)),
													map.get(CLRepeatTable.repDateOne),
													mMap.get(ScheduleTable.schRepeatDate),
													Integer.parseInt(map
															.get(CLRepeatTable.repStateOne)),
													2);
								} else if (!"".equals(lastdate) && "".equals(nextdate)) {
									application
											.updateSchCLRepeatData(
													Integer.parseInt(mMap
															.get(ScheduleTable.schRepeatID)),
													mMap.get(ScheduleTable.schRepeatDate),
													map.get(CLRepeatTable.repDateTwo),
													2,
													Integer.parseInt(map
															.get(CLRepeatTable.repStateTwo)));
								} else {
									if (DateUtil.parseDateTime(lastdate).getTime() > DateUtil
											.parseDateTime(nextdate).getTime()) {
										application
												.updateSchCLRepeatData(
														Integer.parseInt(mMap
																.get(ScheduleTable.schRepeatID)),
														map.get(CLRepeatTable.repDateOne),
														mMap.get(ScheduleTable.schRepeatDate),
														Integer.parseInt(map
																.get(CLRepeatTable.repStateOne)),
														2);
									} else {
										application
												.updateSchCLRepeatData(
														Integer.parseInt(mMap
																.get(ScheduleTable.schRepeatID)),
														mMap.get(ScheduleTable.schRepeatDate),
														map.get(CLRepeatTable.repDateTwo),
														2,
														Integer.parseInt(map
																.get(CLRepeatTable.repStateTwo)));
									}
								}
							}
						}
					}
					// mList.remove(position);
					loadData();
					adapter.notifyDataSetChanged();
					important_listview.invalidate();
					RefreshMyData();
					if (DateUtil.parseDateTime(
							DateUtil.formatDateTime(new Date())).getTime() >= DateUtil
							.parseDateTime(
									mMap.get(ScheduleTable.schDate) + " "
											+ mMap.get(ScheduleTable.schTime))
							.getTime()) {
						QueryAlarmData.writeAlarm(getActivity()
								.getApplicationContext());

					}
				}
			}
		});
		TextView delete_canel = (TextView) window
				.findViewById(R.id.delete_canel);
		delete_canel.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				builder.cancel();
			}
		});
		TextView delete_tv = (TextView) window.findViewById(R.id.delete_tv);
		if (type == 0) {
			delete_tv.setText("确定要删除此记事吗?");
		} else {
			delete_tv.setText("结束今天之前所有未结束的记事?");
		}

	}
	/**
	 * 删除日程
	 *
	 */
	private void deleteItem(final Map<String, String> mMap) {
		final AlertDialog builder = new AlertDialog.Builder(context)
				.create();

		builder.show();
		Window window = builder.getWindow();
		android.view.WindowManager.LayoutParams params = window.getAttributes();// 获取LayoutParams
		params.alpha = 0.92f;
		window.setAttributes(params);// 设置生效
		window.setContentView(R.layout.dialog_alterdelete);
		TextView delete_ok = (TextView) window.findViewById(R.id.delete_ok);
		TextView delete_canel = (TextView) window
				.findViewById(R.id.delete_canel);
		delete_canel.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				adapter.notifyDataSetChanged();
				builder.dismiss();
			}
		});
		TextView delete_tv = (TextView) window.findViewById(R.id.delete_tv);

		delete_tv.setText("确定要结束此日程吗?");

		delete_ok.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {

				endCalender(mMap);
				builder.dismiss();
			}
		});
	}

	private void endCalender( Map<String, String> mMap){
		try {
			// if ("0".equals(mMap.get(ScheduleTable.schIsEnd))) {
			// soundstate = sharedPrefUtil.getString(getActivity(),
			// ShareFile.USERFILE, ShareFile.ENDSOUNDSTATE,
			// "0");
			// wakestate = sharedPrefUtil
			// .getString(getActivity(), ShareFile.USERFILE,
			// ShareFile.ENDWAKESTATE, "0");
			// if ("0".equals(soundstate)) {
			// MediaPlayer mediaPlayer = mediaPlayer = new
			// MediaPlayer();
			// AssetFileDescriptor fileDescriptor = getActivity()
			// .getAssets().openFd("complete.mp3");
			// mediaPlayer.setDataSource(
			// fileDescriptor.getFileDescriptor(),
			// fileDescriptor.getStartOffset(),
			// fileDescriptor.getLength());
			// mediaPlayer.prepare();
			// mediaPlayer.start();
			// }
			// if ("0".equals(wakestate)) {
			// long[] pattern = { 100, 400 }; // 停止 开启 停止 开启
			// vibrator.vibrate(pattern, -1); // 重复两次上面的pattern
			// // 如果只想震动一次，index设为-1
			// }
			// }
			if ("0".equals(mMap.get(ScheduleTable.schRepeatID))) {
				// updateScheduleRead1(mMap, ScheduleTable.schRead);
			} else {
				updateScheduleRead2(mMap, ScheduleTable.schRead,
						ScheduleTable.schRepeatLink);
			}
			// updateFocusStateSch(mMap, ScheduleTable.schFocusState);
			updateScheduleIsEnd(mMap, ScheduleTable.schIsEnd,
					ScheduleTable.schUpdateState);
			updateSchClock(mMap, LocateAllNoticeTable.isEnd);
			adapter.notifyDataSetChanged();
			sharedPrefUtil.putString(context, ShareFile.USERFILE,
					ShareFile.ENDUPDATETIME,
					DateUtil.formatDateTimeSs(new Date()));
			final String updatetime = sharedPrefUtil.getString(context,
					ShareFile.USERFILE, ShareFile.ENDUPDATETIME,
					DateUtil.formatDateTimeSs(new Date()));
			handler.postDelayed(new Runnable() {
				@Override
				public void run() {
					String delaytime = DateUtil
							.formatDateTimeSs(new Date());
					if (DateUtil.parseDateTimeSs(delaytime).getTime()
							- DateUtil.parseDateTimeSs(updatetime)
							.getTime() >= 3000) {
						UpLoadData();
					}
				}
			}, 3000);
		} catch (Exception e) {
			e.printStackTrace();
		}
		if (DateUtil.parseDateTime(DateUtil.formatDateTime(new Date()))
				.getTime() >= DateUtil.parseDateTime(
				mMap.get(ScheduleTable.schDate) + " "
						+ mMap.get(ScheduleTable.schTime)).getTime()) {
			QueryAlarmData.writeAlarm(getActivity()
					.getApplicationContext());
		}
	}
	/**
	 * 普通记事点击弹出详情菜单 setType 0,菜单详情 1,设置
	 * 
	 * @param
	 */

	private void dialogDetailOnClick(Map<String, String> mMaps,
									 final int position) {
		final Dialog dialog = new Dialog(context, R.style.dialog_translucent);
		Window window = dialog.getWindow();
		WindowManager.LayoutParams params = window.getAttributes();// 获取LayoutParams
		params.alpha = 0.92f;
		window.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL);
		window.setAttributes(params);// 设置生效

		LayoutInflater fac = LayoutInflater.from(context);
		View more_pop_menu = fac.inflate(R.layout.dialog_calender_new_detail, null);
		dialog.setCanceledOnTouchOutside(true);
		dialog.setContentView(more_pop_menu);
		params.height = ViewGroup.LayoutParams.WRAP_CONTENT;
		params.width = getActivity().getWindowManager().getDefaultDisplay()
				.getWidth() - 30;
		dialog.show();

		final Map<String, String> mMap = mMaps;


		List<View> viewList = new ArrayList<View>();


		MyViewPager myViewPager = (MyViewPager) more_pop_menu.findViewById(R.id.viewpager_detail);

		View viewOne = LayoutInflater.from(context).inflate(R.layout.dialog_calender_new_detail_item1, null);
		View viewTwo = LayoutInflater.from(context).inflate(R.layout.dialog_calender_new_detail_item2, null);
//        applyBlur(viewOne);
//        applyBlur(viewTwo);

		final Calendar calendar = Calendar.getInstance();
		calendar.setTime(new Date());
		String today = DateUtil.formatDate(calendar.getTime());
		calendar.set(Calendar.DAY_OF_MONTH,
				calendar.get(Calendar.DAY_OF_MONTH) + 1);
		String tomorrow = DateUtil.formatDate(calendar.getTime());

		final int id = Integer.parseInt(mMap.get(ScheduleTable.schID));


		final Map<String, String> map = App.getDBcApplication().QueryStateData(
				Integer.parseInt(mMap.get(ScheduleTable.schRepeatID)));

		final Intent intent = new Intent();

		final MySchBean mySchBean = new MySchBean();
		mySchBean.schID = mMap.get(ScheduleTable.schID);
		mySchBean.schContent = mMap.get(ScheduleTable.schContent);
		mySchBean.schDate = mMap.get(ScheduleTable.schDate);
		mySchBean.schTime = mMap.get(ScheduleTable.schTime);
		mySchBean.schIsAlarm = mMap.get(ScheduleTable.schIsAlarm);
		mySchBean.schBeforeTime = mMap.get(ScheduleTable.schBeforeTime);
		mySchBean.schDisplayTime = mMap.get(ScheduleTable.schDisplayTime);
		mySchBean.schIsPostpone = mMap.get(ScheduleTable.schIsPostpone);
		mySchBean.schIsImportant = mMap.get(ScheduleTable.schIsImportant);
		mySchBean.schColorType = mMap.get(ScheduleTable.schColorType);
		mySchBean.schIsEnd = mMap.get(ScheduleTable.schIsEnd);
		mySchBean.schCreateTime = mMap.get(ScheduleTable.schCreateTime);
		mySchBean.schTags = mMap.get(ScheduleTable.schTags);
		mySchBean.schSourceType = mMap.get(ScheduleTable.schSourceType);
		mySchBean.schSourceDesc = mMap.get(ScheduleTable.schSourceDesc);
		mySchBean.schSourceDescSpare = mMap
				.get(ScheduleTable.schSourceDescSpare);
		mySchBean.schRepeatID = mMap.get(ScheduleTable.schRepeatID);
		mySchBean.schRepeatDate = mMap.get(ScheduleTable.schRepeatDate);
		mySchBean.schUpdateTime = mMap.get(ScheduleTable.schUpdateTime);
		mySchBean.schUpdateState = mMap.get(ScheduleTable.schUpdateState);
		mySchBean.schOpenState = mMap.get(ScheduleTable.schOpenState);
		mySchBean.schRepeatLink = mMap.get(ScheduleTable.schRepeatLink);
		mySchBean.schRingDesc = mMap.get(ScheduleTable.schRingDesc);
		mySchBean.schRingCode = mMap.get(ScheduleTable.schRingCode);
		mySchBean.schcRecommendName = mMap
				.get(ScheduleTable.schcRecommendName);
		mySchBean.schRead = mMap.get(ScheduleTable.schRead);

		/*****第一页****/

		final ImageView shunyan_image = (ImageView) viewOne.findViewById(R.id.shunyan_image);
		final TextView shunyan_tv = (TextView) viewOne.findViewById(R.id.shunyan_tv);
		final ImageView important_image = (ImageView) viewOne.findViewById(R.id.important_image);
		final TextView important_tv = (TextView) viewOne.findViewById(R.id.important_tv);
		final ImageView end_image = (ImageView) viewOne.findViewById(R.id.end_image);
		final TextView end_tv = (TextView) viewOne.findViewById(R.id.end_tv);
		final TextView bianji = (TextView) viewOne.findViewById(R.id.bianji);
		final TextView fenlei = (TextView) viewOne.findViewById(R.id.fenlei);
		final TextView date_tv = (TextView) viewOne.findViewById(R.id.date_tv);
		final TextView time_tv = (TextView) viewOne.findViewById(R.id.time_tv);
		final TextView day = (TextView) viewOne.findViewById(R.id.day);
		final TextView week = (TextView) viewOne.findViewById(R.id.week);
		final TextView month = (TextView) viewOne.findViewById(R.id.month);
		int colortype = Integer.parseInt(mMap.get(ScheduleTable.schColorType));
		String colorname = application.QueryTagNameData(colortype).get("ctgText");
		if (colorname.equals("未分类")) {
			fenlei.setText(colorname + "\n分类设置");
		} else {
			String htmlstr = "<font color='#aaaaaa'>" + colorname + "</font><br>分类设置";
			fenlei.setText(Html.fromHtml(htmlstr));
		}

		date_tv.setText(mMap.get(ScheduleTable.schDate) + "\n设置日期");
		if (mMap.get(ScheduleTable.schDisplayTime).equals("0")) {
			time_tv.setText("全天\n设置时间");
		} else {
			time_tv.setText(mMap.get(ScheduleTable.schTime) + "\n设置时间");
		}

		if (mMap.get(ScheduleTable.schDate).compareTo(DateUtil.nowTodyTime()) <= 0) {
			day.setText("推到明天");
			week.setText("推到下周");
			month.setText("推到下月");
		} else {
			day.setText("推后一天");
			week.setText("推后一周");
			month.setText("推后一月");
		}

		day.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				try {
					updateFocusStateSch(mMap, ScheduleTable.schFocusState);
					String date = inWeekUtils.AfterOneDay(mMap.get(ScheduleTable.schDate));
					App.getDBcApplication().updateScheduleDateData(id, date,
							mMap.get(ScheduleTable.schTime));
					App.getDBcApplication().updateSchReadData(
							Integer.parseInt(mMap.get(ScheduleTable.schID)), 0);
					App.getDBcApplication().updateSchRepeatLinkData(
							Integer.parseInt(mMap.get(ScheduleTable.schID)), 0);
					if ("".equals(mMap.get(ScheduleTable.schRepeatDate))
							|| "0".equals(mMap.get(ScheduleTable.schRepeatLink))) {

					} else {
						if (map != null) {
							String repdate = mMap
									.get(ScheduleTable.schRepeatDate);
							String lastdate = StringUtils.getIsStringEqulesNull(map
									.get(CLRepeatTable.repDateOne));
							String nextdate = StringUtils.getIsStringEqulesNull(map
									.get(CLRepeatTable.repDateTwo));
							repeatSetChildEndUtils.setParentState(Integer.parseInt(mMap
									.get(ScheduleTable.schRepeatID)), repdate, nextdate, lastdate, map);
						}
					}

					loadData();
					adapter.notifyDataSetChanged();
					QueryAlarmData.writeAlarm(context);

					Intent intentf = new Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
					Bundle extras = new Bundle();
					intentf.putExtras(extras);
					getActivity().sendBroadcast(intentf);
				} catch (Exception e) {
					e.printStackTrace();
				}
				dialog.dismiss();
			}
		});
		week.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				try {
					updateFocusStateSch(mMap, ScheduleTable.schFocusState);
					String date = inWeekUtils.AfterOneWeek(mMap.get(ScheduleTable.schDate));
					App.getDBcApplication().updateScheduleDateData(id, date,
							mMap.get(ScheduleTable.schTime));
					App.getDBcApplication().updateSchReadData(
							Integer.parseInt(mMap.get(ScheduleTable.schID)), 0);
					App.getDBcApplication().updateSchRepeatLinkData(
							Integer.parseInt(mMap.get(ScheduleTable.schID)), 0);
					if ("".equals(mMap.get(ScheduleTable.schRepeatDate))
							|| "0".equals(mMap.get(ScheduleTable.schRepeatLink))) {

					} else {
						if (map != null) {
							String repdate = mMap
									.get(ScheduleTable.schRepeatDate);
							String lastdate = StringUtils.getIsStringEqulesNull(map
									.get(CLRepeatTable.repDateOne));
							String nextdate = StringUtils.getIsStringEqulesNull(map
									.get(CLRepeatTable.repDateTwo));
							repeatSetChildEndUtils.setParentState(Integer.parseInt(mMap
									.get(ScheduleTable.schRepeatID)), repdate, nextdate, lastdate, map);
						}
					}

					loadData();
					adapter.notifyDataSetChanged();
					QueryAlarmData.writeAlarm(context);

					Intent intentf = new Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
					Bundle extras = new Bundle();
					intentf.putExtras(extras);
					getActivity().sendBroadcast(intentf);
				} catch (Exception e) {
					e.printStackTrace();
				}
				dialog.dismiss();
			}
		});
		month.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				try {
					updateFocusStateSch(mMap, ScheduleTable.schFocusState);
					String date = inWeekUtils.AfterOneMonth(mMap.get(ScheduleTable.schDate));
					App.getDBcApplication().updateScheduleDateData(id, date,
							mMap.get(ScheduleTable.schTime));
					App.getDBcApplication().updateSchReadData(
							Integer.parseInt(mMap.get(ScheduleTable.schID)), 0);
					App.getDBcApplication().updateSchRepeatLinkData(
							Integer.parseInt(mMap.get(ScheduleTable.schID)), 0);
					if ("".equals(mMap.get(ScheduleTable.schRepeatDate))
							|| "0".equals(mMap.get(ScheduleTable.schRepeatLink))) {

					} else {
						if (map != null) {
							String repdate = mMap
									.get(ScheduleTable.schRepeatDate);
							String lastdate = StringUtils.getIsStringEqulesNull(map
									.get(CLRepeatTable.repDateOne));
							String nextdate = StringUtils.getIsStringEqulesNull(map
									.get(CLRepeatTable.repDateTwo));
							repeatSetChildEndUtils.setParentState(Integer.parseInt(mMap
									.get(ScheduleTable.schRepeatID)), repdate, nextdate, lastdate, map);
						}
					}

					loadData();
					adapter.notifyDataSetChanged();

					QueryAlarmData.writeAlarm(context);

					Intent intentf = new Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
					Bundle extras = new Bundle();
					intentf.putExtras(extras);
					getActivity().sendBroadcast(intentf);
				} catch (Exception e) {
					e.printStackTrace();
				}
				dialog.dismiss();
			}
		});


		if ("0".equals(mMap.get(ScheduleTable.schIsPostpone))) {
			shunyan_image.setBackground(getResources().getDrawable(R.mipmap.anniu_shun_hui));
			shunyan_tv.setText("自动顺延");
		} else {
			shunyan_image.setBackground(getResources().getDrawable(R.mipmap.anniu_shun_lv));
			shunyan_tv.setText("取消顺延");
		}

		if ("0".equals(mMap.get(ScheduleTable.schIsImportant))) {
			important_image.setBackground(getResources().getDrawable(R.mipmap.anniu_zhongyao_hui));
			important_tv.setText("设为重要");
		} else {
			important_image.setBackground(getResources().getDrawable(R.mipmap.anniu_zhongyao_lv));
			important_tv.setText("取消重要");
		}

		if ("1".equals(mMap.get(ScheduleTable.schIsEnd))) {
			end_image.setBackground(getResources().getDrawable(R.mipmap.anniu_jiesu_lv));
			end_tv.setText("已结束");
		} else {
			end_image.setBackground(getResources().getDrawable(R.mipmap.anniu_jiesu_hui));
			end_tv.setText("未结束");
		}

		date_tv.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				initRiliDiaLog(date_tv, mMap);
			}
		});

		time_tv.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				initDiaLog(time_tv, mMap);
			}
		});

		//顺延
		shunyan_image.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {

				String date;

				if ("0".equals(mMap.get(ScheduleTable.schIsPostpone))) {
					shunyan_image.setBackground(getResources().getDrawable(R.mipmap.anniu_shun_lv));
					shunyan_tv.setText("取消顺延");
				} else {
					shunyan_image.setBackground(getResources().getDrawable(R.mipmap.anniu_shun_hui));
					shunyan_tv.setText("自动顺延");
				}
				updateSchedule(mMap, ScheduleTable.schIsPostpone,
						ScheduleTable.schUpdateState);
				updateSchClock(mMap, LocateAllNoticeTable.postpone);
				updateFocusStateSch(mMap, ScheduleTable.schFocusState);
				calendar.setTime(DateUtil.parseDate(mMap
						.get(ScheduleTable.schDate)));
				if (DateUtil.parseDate(mMap.get(ScheduleTable.schDate)).before(
						DateUtil.parseDate(DateUtil.formatDate(new Date())))) {
					calendar.set(Calendar.DAY_OF_MONTH,
							calendar.get(Calendar.DAY_OF_MONTH) + 1);
					date = DateUtil.formatDate(calendar.getTime());
					App.getDBcApplication().updateScheduleDateData(id, date,
							mMap.get(ScheduleTable.schTime));
				}

				App.getDBcApplication().updateSchReadData(
						Integer.parseInt(mMap.get(ScheduleTable.schID)), 0);
				App.getDBcApplication().updateSchRepeatLinkData(
						Integer.parseInt(mMap.get(ScheduleTable.schID)), 0);
				if ("".equals(mMap.get(ScheduleTable.schRepeatDate))
						|| "0".equals(mMap.get(ScheduleTable.schRepeatLink))) {

				} else {
					if (map != null) {
						String repdate = mMap
								.get(ScheduleTable.schRepeatDate);
						String lastdate = StringUtils.getIsStringEqulesNull(map
								.get(CLRepeatTable.repDateOne));
						String nextdate = StringUtils.getIsStringEqulesNull(map
								.get(CLRepeatTable.repDateTwo));
						repeatSetChildEndUtils.setParentState(Integer.parseInt(mMap
								.get(ScheduleTable.schRepeatID)), repdate, nextdate, lastdate, map);
					}
				}
				loadData();
				adapter.notifyDataSetChanged();
				QueryAlarmData.writeAlarm(context);
			}
		});

		//重要
		important_image.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				if ("0".equals(mMap.get(ScheduleTable.schIsImportant))) {
					important_image.setBackground(getResources().getDrawable(R.mipmap.anniu_zhongyao_lv));
					important_tv.setText("取消重要");
				} else {
					important_image.setBackground(getResources().getDrawable(R.mipmap.anniu_zhongyao_hui));
					important_tv.setText("设为重要");
				}
				try {
					updateFocusStateSch(mMap, ScheduleTable.schFocusState);
					App.getDBcApplication().updateSchReadData(
							Integer.parseInt(mMap.get(ScheduleTable.schID)), 0);
					App.getDBcApplication().updateSchRepeatLinkData(
							Integer.parseInt(mMap.get(ScheduleTable.schID)), 0);
					if (!"".equals(mMap.get(ScheduleTable.schRepeatDate))
							&& !"0".equals(mMap
							.get(ScheduleTable.schRepeatLink))) {
						if (map != null) {
							String repdate = mMap
									.get(ScheduleTable.schRepeatDate);
							String lastdate = StringUtils.getIsStringEqulesNull(map
									.get(CLRepeatTable.repDateOne));
							String nextdate = StringUtils.getIsStringEqulesNull(map
									.get(CLRepeatTable.repDateTwo));
							repeatSetChildEndUtils.setParentState(Integer.parseInt(mMap
									.get(ScheduleTable.schRepeatID)), repdate, nextdate, lastdate, map);
						}
						updateRepSchUpdate(mMap, ScheduleTable.schIsImportant,
								ScheduleTable.schUpdateState);
					} else {
						updateSchedule(mMap, ScheduleTable.schIsImportant,
								ScheduleTable.schUpdateState);
					}
					loadData();adapter.notifyDataSetChanged();
					QueryAlarmData.writeAlarm(context);
				} catch (Exception e) {
					e.printStackTrace();
				}


			}
		});

		//结束
		end_image.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				if ("1".equals(mMap.get(ScheduleTable.schIsEnd))) {
					end_image.setBackground(getResources().getDrawable(R.mipmap.anniu_jiesu_hui));
					end_tv.setText("未结束");
				} else {
					end_image.setBackground(getResources().getDrawable(R.mipmap.anniu_jiesu_lv));
					end_tv.setText("已结束");
				}
				if (Integer.valueOf(mMap.get(ScheduleTable.schcRecommendId)) > 0
						&& Integer.valueOf(mMap.get(ScheduleTable.schAID)) == 0) {
					if (!mMap.get(ScheduleTable.schRepeatID).equals("0")) {
						sharedPrefUtil.putString(context,
								ShareFile.USERFILE,
								ShareFile.UPLOADTYPE,
								"1");
						endCalender(mMap);
					} else {
						sharedPrefUtil.putString(context,
								ShareFile.USERFILE,
								ShareFile.UPLOADTYPE,
								"0");
						deleteItem(mMap);
					}

				} else {
					sharedPrefUtil.putString(context,
							ShareFile.USERFILE,
							ShareFile.UPLOADTYPE,
							"1");
					endCalender(mMap);
				}


				if ("1".equals(mMap.get(ScheduleTable.schRepeatLink))
						|| "3".equals(mMap.get(ScheduleTable.schRepeatLink))) {
					repeatSetChildEndUtils.setParentStateIsEnd(mMap);
				}
				String value = "0";
				if ("0".equals(mMap.get(ScheduleTable.schIsEnd)))
					value = "1";
				else
					value = "0";
				mMap.put(ScheduleTable.schIsEnd, value);
				if ("1".equals(mMap.get(ScheduleTable.schRepeatLink))
						|| "3".equals(mMap.get(ScheduleTable.schRepeatLink))) {
					mMap.put(ScheduleTable.schUpdateState, "0");
				} else {
					mMap.put(ScheduleTable.schUpdateState, "2");
				}


				Intent intentf = new Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
				Bundle extras = new Bundle();
				intentf.putExtras(extras);
				getActivity().sendBroadcast(intentf);
			}
		});

		//编辑
		bianji.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				intent.putExtra("id", mMap.get(ScheduleTable.schID));
				intent.putExtra("content", mMap.get(ScheduleTable.schContent));
				intent.putExtra("year", mMap.get(ScheduleTable.schDate));
				intent.putExtra("time", mMap.get(ScheduleTable.schTime));
				intent.putExtra("week", CharacterUtil.getWeekOfDate(context,DateUtil.parseDate(mMap.get(ScheduleTable.schDate))));
				intent.putExtra("tixing", mMap.get(ScheduleTable.schBeforeTime));
				intent.putExtra("beforetime",
						mMap.get(ScheduleTable.schBeforeTime));
				intent.putExtra("openState",
						mMap.get(ScheduleTable.schOpenState));
				intent.putExtra("lingshengname",
						mMap.get(ScheduleTable.schRingDesc));
				intent.putExtra("ringcode", mMap.get(ScheduleTable.schRingCode));
				intent.putExtra("recommendID",
						mMap.get(ScheduleTable.schcRecommendId));
				intent.putExtra("recommendname",
						mMap.get(ScheduleTable.schcRecommendName));
				intent.putExtra("repid", mMap.get(ScheduleTable.schRepeatID));
				intent.putExtra("repdate",
						mMap.get(ScheduleTable.schRepeatDate));
				intent.putExtra("replink",
						mMap.get(ScheduleTable.schRepeatLink));
				intent.putExtra("aid", mMap.get(ScheduleTable.schAID));
				intent.putExtra("friendID", mMap.get(ScheduleTable.schFriendID));
				intent.putExtra("schIsAlarm",
						mMap.get(ScheduleTable.schIsAlarm));
				intent.putExtra("postpone",
						mMap.get(ScheduleTable.schIsPostpone));
				intent.putExtra("important",
						mMap.get(ScheduleTable.schIsImportant));
				intent.putExtra("coclor", mMap.get(ScheduleTable.schColorType));
				intent.putExtra("isEnd", mMap.get(ScheduleTable.schIsEnd));
				intent.putExtra("displaytime",
						mMap.get(ScheduleTable.schDisplayTime));
				intent.putExtra("schType", "0");
				startActivityForResult(intent.setClass(context,AddEverydayDetailTaskActivity.class), 100);
				dialog.dismiss();
			}
		});

		//分类
		fenlei.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				try {
					App.getDBcApplication().updateSchReadData(
							Integer.parseInt(mMap.get(ScheduleTable.schID)), 0);
					App.getDBcApplication().updateSchRepeatLinkData(
							Integer.parseInt(mMap.get(ScheduleTable.schID)), 0);
					if ("".equals(mMap.get(ScheduleTable.schRepeatDate))
							|| "0".equals(mMap.get(ScheduleTable.schRepeatLink))) {

					} else {
						if (map != null) {
							String repdate = mMap
									.get(ScheduleTable.schRepeatDate);
							String lastdate = StringUtils.getIsStringEqulesNull(map
									.get(CLRepeatTable.repDateOne));
							String nextdate = StringUtils.getIsStringEqulesNull(map
									.get(CLRepeatTable.repDateTwo));
							repeatSetChildEndUtils.setParentState(Integer.parseInt(mMap
									.get(ScheduleTable.schRepeatID)), repdate, nextdate, lastdate, map);
						}
					}
					updateFocusStateSch(mMap, ScheduleTable.schFocusState);
					loadData();
					adapter.notifyDataSetChanged();
					intent.putExtra("statename", fenlei.getText().toString());
					intent.putExtra("id", mMap.get(ScheduleTable.schID));
					startActivityForResult(intent.setClass(context, MyStateActivity.class), 100);
				} catch (Exception e) {
					e.printStackTrace();
				}
				dialog.dismiss();
			}
		});


		/*****第二页****/

		TextView delete = (TextView) viewTwo.findViewById(R.id.delete);
		TextView shitinglings = (TextView) viewTwo.findViewById(R.id.shitinglings);
		TextView zhaunfaweixin = (TextView) viewTwo.findViewById(R.id.zhaunfaweixin);
		TextView zhaunfahaoyou = (TextView) viewTwo.findViewById(R.id.zhaunfahaoyou);
		TextView copy_calender = (TextView) viewTwo.findViewById(R.id.copy_calender);
		TextView copy_content = (TextView) viewTwo.findViewById(R.id.copy_content);
		TextView top = (TextView) viewTwo.findViewById(R.id.top);
		TextView wanchengrenwu = (TextView) viewTwo.findViewById(R.id.wanchengrenwu);
		LinearLayout top_ll = (LinearLayout) viewTwo.findViewById(R.id.top_ll);
		LinearLayout lings_ll = (LinearLayout) viewTwo.findViewById(R.id.lings_ll);
		final TextView tixingshijain = (TextView) viewTwo.findViewById(R.id.tixingshijain);
		TextView add_note = (TextView) viewTwo.findViewById(R.id.add_note);

		wanchengrenwu.setText(mMap.get(ScheduleTable.schRingDesc) + "\n铃声设置");


		if (mMap.get(ScheduleTable.schDisplayTime).equals("0")
				&& mMap.get(ScheduleTable.schIsPostpone).equals("1")) {
			top_ll.setVisibility(View.VISIBLE);
			lings_ll.setVisibility(View.GONE);
		} else {
			top_ll.setVisibility(View.GONE);
			lings_ll.setVisibility(View.VISIBLE);
		}


		String beforeStr = "准时提醒";
		if (Integer.valueOf(mMap.get(ScheduleTable.schIsAlarm)) == 0 || Integer.valueOf(mMap.get(ScheduleTable.schIsAlarm)) == 1) {
			beforeStr = "准时提醒";
			isAlarm = 1;
			//有提前
		} else if (Integer.valueOf(mMap.get(ScheduleTable.schIsAlarm)) == 2) {
			isAlarm = 2;
			if (Integer.valueOf(mMap.get(ScheduleTable.schBeforeTime)) == 5) {
				beforeStr = "提前5分钟";
			} else if (Integer.valueOf(mMap.get(ScheduleTable.schBeforeTime)) == 15) {
				beforeStr = "提前15分钟";
			} else if (Integer.valueOf(mMap.get(ScheduleTable.schBeforeTime)) == 30) {
				beforeStr = "提前30分钟";
			} else if (Integer.valueOf(mMap.get(ScheduleTable.schBeforeTime)) == 60) {
				beforeStr = "提前1小时";
			} else if (Integer.valueOf(mMap.get(ScheduleTable.schBeforeTime)) == 120) {
				beforeStr = "提前2小时";
			} else if (Integer.valueOf(mMap.get(ScheduleTable.schBeforeTime)) == 24 * 60) {
				beforeStr = "提前1天";
			} else if (Integer.valueOf(mMap.get(ScheduleTable.schBeforeTime)) == 48 * 60) {
				beforeStr = "提前2天";
			} else if (Integer.valueOf(mMap.get(ScheduleTable.schBeforeTime)) == 7 * 24 * 60) {
				beforeStr = "提前1周";
			}
			//准时+提前
		} else if (Integer.valueOf(mMap.get(ScheduleTable.schIsAlarm)) == 3) {
			isAlarm = 3;
			if (Integer.valueOf(mMap.get(ScheduleTable.schBeforeTime)) == 5) {
				beforeStr = "准时提醒\n提前5分钟";
			} else if (Integer.valueOf(mMap.get(ScheduleTable.schBeforeTime)) == 15) {
				beforeStr = "准时提醒\n提前15分钟";
			} else if (Integer.valueOf(mMap.get(ScheduleTable.schBeforeTime)) == 30) {
				beforeStr = "准时提醒\n提前30分钟";
			} else if (Integer.valueOf(mMap.get(ScheduleTable.schBeforeTime)) == 60) {
				beforeStr = "准时提醒\n提前1小时";
			} else if (Integer.valueOf(mMap.get(ScheduleTable.schBeforeTime)) == 120) {
				beforeStr = "准时提醒\n提前2小时";
			} else if (Integer.valueOf(mMap.get(ScheduleTable.schBeforeTime)) == 24 * 60) {
				beforeStr = "准时提醒\n提前1天";
			} else if (Integer.valueOf(mMap.get(ScheduleTable.schBeforeTime)) == 48 * 60) {
				beforeStr = "准时提醒\n提前2天";
			} else if (Integer.valueOf(mMap.get(ScheduleTable.schBeforeTime)) == 7 * 24 * 60) {
				beforeStr = "准时提醒\n提前1周";
			}
		}
		tixingshijain.setText(beforeStr);
		initValues(Integer.valueOf(mMap.get(ScheduleTable.schIsAlarm)));

		delete.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				try {
					if (Integer.valueOf(mList.get(position).get(ScheduleTable.schcRecommendId)) > 0
							&& Integer.valueOf(mList.get(position).get(ScheduleTable.schAID)) == 0) {
						sharedPrefUtil.putString(context,
								ShareFile.USERFILE,
								ShareFile.UPLOADTYPE,
								"0");
					} else {
						sharedPrefUtil.putString(context,
								ShareFile.USERFILE,
								ShareFile.UPLOADTYPE,
								"1");

					}
					alertDeleteDialog(mMap, 0, position);
				} catch (Exception e) {
					e.printStackTrace();
				}
				Intent intentd = new Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
				Bundle extrasd = new Bundle();
				intentd.putExtras(extrasd);
				getActivity().sendBroadcast(intentd);
				dialog.dismiss();
			}
		});


		//试听铃声
		shitinglings.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				final MediaPlayer mediaPlayer = new MediaPlayer();

				try {
					AssetFileDescriptor fileDescriptor = context.getAssets().openFd(
							mMap.get(ScheduleTable.schRingCode)
									+ ".mp3");
					mediaPlayer.setDataSource(
							fileDescriptor.getFileDescriptor(),
							fileDescriptor.getStartOffset(),
							fileDescriptor.getLength());
					mediaPlayer.prepare();
					mediaPlayer.start();
				} catch (IllegalArgumentException e) {
					e.printStackTrace();
				} catch (SecurityException e) {
					e.printStackTrace();
				} catch (IllegalStateException e) {
					e.printStackTrace();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		});

		//转发微信
		zhaunfaweixin.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				ShareSDK.initSDK(context);
				OnekeyShare oks = new OnekeyShare();
				// 关闭sso授权
				oks.disableSSOWhenAuthorize();
				oks.setText(mySchBean.schDate + "  " + mySchBean.schTime + "  " + mySchBean.schContent);
				// 启动分享GUI
				oks.show(context);
				dialog.dismiss();
			}
		});
		//转发好友
		zhaunfahaoyou.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				if (sharedPrefUtil.getString(context,
						ShareFile.USERFILE, ShareFile.ISNEWYOUKE, "0").equals("-1")) {
					intent.putExtra("bean", mySchBean);
					startActivity(intent.setClass(context, SchZhuanFaActivity.class));
					dialog.dismiss();
				} else {
					Intent newt = new Intent(context, PhoneCodeLoginActivity.class);
					newt.putExtra("type", 1);
					newt.putExtra("login", true);
					startActivity(newt);
					dialog.dismiss();
				}
			}
		});
		//置顶
		top.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				App.getDBcApplication().updateSceduleDataTop(mMap.get(ScheduleTable.schID), DateUtil.nowTimes(), DateUtil.nowTodyTime());
				loadData();adapter.notifyDataSetChanged();
				QueryAlarmData.writeAlarm(context);

				Intent intentappwidget = new Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
				Bundle extras = new Bundle();
				intentappwidget.putExtras(extras);
				getActivity().sendBroadcast(intentappwidget);
				dialog.dismiss();
			}
		});
		//复制日程
		copy_calender.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				try {
					String before = sharedPrefUtil.getString(context,
							ShareFile.USERFILE, ShareFile.BEFORETIME, "0");
					App.getDBcApplication().insertScheduleData(mMap.get(ScheduleTable.schContent), DateUtil.nowTodyTime(),
							DateUtil.nowTimes(), 1,
							Integer.parseInt(before), Integer.valueOf(mMap.get(ScheduleTable.schDisplayTime)),
							Integer.valueOf(mMap.get(ScheduleTable.schIsPostpone)), 0,
							0, 0, DateUtil.formatDateTime(new Date()), "", 0,
							"", "", 0, "", DateUtil.formatDateTime(new Date()),
							1, 0, 0, mMap.get(ScheduleTable.schRingCode), mMap.get(ScheduleTable.schRingDesc), "", 0, 0, 0, "",
							"", 0, 0, 0,0,"","0","0");
					loadData();adapter.notifyDataSetChanged();
					QueryAlarmData.writeAlarm(context);

					Intent intentappwidget = new Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
					Bundle extras = new Bundle();
					intentappwidget.putExtras(extras);
					getActivity().sendBroadcast(intentappwidget);
				} catch (NumberFormatException e) {
					e.printStackTrace();
				}
				dialog.dismiss();
			}
		});
		//复制文本
		copy_content.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				ClipboardManager cm = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
				// 将文本内容放到系统剪贴板里。
				cm.setText(mMap.get(ScheduleTable.schContent));
				Toast.makeText(context, "已复制", Toast.LENGTH_SHORT).show();
				dialog.dismiss();
			}
		});
		//选择铃声
		wanchengrenwu.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent intent = new Intent(context, LingShengActivity.class);
				intent.putExtra("schID", mMap.get(ScheduleTable.schID));
				startActivityForResult(intent, 100);
				dialog.dismiss();
			}
		});
		//提醒时间
		tixingshijain.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				if (mMap.get(ScheduleTable.schDisplayTime).equals("0")) {
					Toast.makeText(context, "全天日程不能设置提前提醒时间", Toast.LENGTH_SHORT).show();
				} else {
					initBeforeDiaLog(tixingshijain, mMap);
				}

			}
		});
		//加入清单
		add_note.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent intenty = new Intent(context, NoteListActivity.class);
				intenty.putExtra("content", mMap.get(ScheduleTable.schContent));
				intenty.putExtra("maxTitleId", "0.1");
				startActivityForResult(intenty, 100);
				dialog.dismiss();
			}
		});

		viewList.add(viewOne);
		viewList.add(viewTwo);

		ViewAdapter viewAdapter = new ViewAdapter(viewList);
		myViewPager.setAdapter(viewAdapter);

		final ImageView yd1 = (ImageView) more_pop_menu.findViewById(R.id.yd1);
		final ImageView yd2 = (ImageView) more_pop_menu.findViewById(R.id.yd2);

		myViewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
			@Override
			public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

			}

			@Override
			public void onPageSelected(int position) {
				yd1.setBackground(getResources().getDrawable(R.drawable.calender_new_detail_yd1));
				yd2.setBackground(getResources().getDrawable(R.drawable.calender_new_detail_yd1));
				if (position == 0) {
					yd1.setBackground(getResources().getDrawable(R.drawable.calender_new_detail_yd2));
				}
				if (position == 1) {
					yd2.setBackground(getResources().getDrawable(R.drawable.calender_new_detail_yd2));
				}
			}

			@Override
			public void onPageScrollStateChanged(int state) {

			}
		});
	}


	private void initDiaLog(TextView time_tv, Map<String, String> mMap) {
		Dialog dialog = new Dialog(context, R.style.dialog_translucent);
		Window window = dialog.getWindow();
		WindowManager.LayoutParams params = window.getAttributes();// 获取LayoutParams
		params.alpha = 0.92f;
		window.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL);
		window.setAttributes(params);// 设置生效

		LayoutInflater fac = LayoutInflater.from(context);
		View more_pop_menu = fac.inflate(R.layout.dialog_calender_time, null);
		dialog.setCanceledOnTouchOutside(true);
		dialog.setContentView(more_pop_menu);
		params.height = ViewGroup.LayoutParams.WRAP_CONTENT;
		params.width = getActivity().getWindowManager().getDefaultDisplay().getWidth() - 30;
		dialog.show();

		new MyClick(dialog, more_pop_menu, time_tv, mMap);
	}

	class MyClick implements View.OnClickListener {

		private Dialog dialog;
		private RelativeLayout rela_hour;
		private RelativeLayout rela_minutes;
		private int hours = 12;
		private int minutes = 0;
		private int width;
		private int centerX;
		private int centerY;
		private Calendar calendar;
		private int lastMinutes;
		private TextView dialog_tv_state;
		private int grState;// 结果为0是上午 结果为1是下午
		private String chooseHour;
		private String chooseMinute;

		private TextView tv_clock_state;
		private LinearLayout ll_clock;
		private TextView tv_clock_time;
		private TextView tv_clock_beforetime;
		private TextView time_tv;

		private RelativeLayout date_re;
		Map<String, String> mMap;
		String time;

		private MyClick(Dialog dialog, View more_pop_menu, TextView time_tvs, Map<String, String> mMap) {
			this.dialog = dialog;
			this.time_tv = time_tvs;
			this.mMap = mMap;
			time = mMap.get(ScheduleTable.schTime);
			calendar = Calendar.getInstance();
			// if (isNeedPush) {
			String[] times;

			if ("全天".equals(time)) {
				times = sharedPrefUtil.getString(context, ShareFile.USERFILE,
						ShareFile.ALLTIME, "08:58").split(":");
			} else {
				times = time.split(":");
			}
			calendar.set(Calendar.HOUR_OF_DAY, Integer.parseInt(times[0]));
			calendar.set(Calendar.MINUTE, Integer.parseInt(times[1]));
			// }
			rela_hour = (RelativeLayout) more_pop_menu
					.findViewById(R.id.rela_hour);
			rela_minutes = (RelativeLayout) more_pop_menu
					.findViewById(R.id.rela_minutes);

			dialog_tv_state = (TextView) more_pop_menu
					.findViewById(R.id.dialog_tv_state);
			date_re = (RelativeLayout) more_pop_menu
					.findViewById(R.id.date_re);
			dialog_tv_state.setOnClickListener(this);
			tv_clock_state = (TextView) more_pop_menu
					.findViewById(R.id.tv_clock_state);
			tv_clock_state.setOnClickListener(this);
			ll_clock = (LinearLayout) more_pop_menu.findViewById(R.id.ll_clock);
			ll_clock.setOnClickListener(this);

			tv_clock_time = (TextView) more_pop_menu
					.findViewById(R.id.tv_clock_time);
			tv_clock_beforetime = (TextView) more_pop_menu
					.findViewById(R.id.tv_clock_beforetime);

			width = getActivity().getWindowManager().getDefaultDisplay().getWidth();
			int haf = Utils.dipTopx(context, 40) / 2;
			centerX = width / 2 - Utils.dipTopx(context, 16);
			centerY = width / 2 - Utils.dipTopx(context, 16) - haf;

			initclockValue();
			initHour();
			initMinutes();

			grState = calendar.get(Calendar.AM_PM);
			if (grState == 0) {// 结果为0是上午 结果为1是下午
				dialog_tv_state.setText("上午");
			} else {
				dialog_tv_state.setText("下午");
			}
		}

		private void initclockValue() {
			tv_clock_time.setText(time);
		}

		private void initHour() {
			int hour = calendar.get(Calendar.HOUR);
			if (hour == 0) {
				hour = 12;
			}
			int hourRadius = Utils.dipTopx(context, 90); // 设置圆半径
			for (int i = 12; i >= 1; i--) {
				int dy = (int) (hourRadius * Math.cos((Math.PI / 6.0) * i));
				int dx = (int) (hourRadius * Math.sin((Math.PI / 6.0) * i));

				int x1 = centerX + dx;
				int y1 = centerY - dy;

				String text = hours < 10 ? "0" + hours : "" + hours;

				TextView textView = new TextView(context);
				textView.setText(text);
				textView.setTextColor(Color.WHITE);
				textView.setTextSize(18.0f);
				textView.setGravity(Gravity.CENTER);
				textView.setLayoutParams(new LinearLayout.LayoutParams(
						LinearLayout.LayoutParams.WRAP_CONTENT,
						LinearLayout.LayoutParams.WRAP_CONTENT));
				textView.setTag(i);
				textView.setOnClickListener(new View.OnClickListener() {

					@Override
					public void onClick(View v) {
						chooseHour = v.getTag().toString();
						chageHour(Integer.parseInt(chooseHour));
						calendar.set(Calendar.HOUR,
								Integer.parseInt(chooseHour));
						calendar.set(Calendar.MINUTE,
								Integer.parseInt(chooseMinute));
						if (grState == 0) {// 上午
							calendar.set(Calendar.AM_PM, 0);
						} else if (grState == 1) {// 下午
							calendar.set(Calendar.AM_PM, 1);
						}
						String calendarHour = calendar
								.get(Calendar.HOUR_OF_DAY) < 10 ? "0"
								+ calendar.get(Calendar.HOUR_OF_DAY) : ""
								+ calendar.get(Calendar.HOUR_OF_DAY);
						String calendarMinute = calendar.get(Calendar.MINUTE) < 10 ? "0"
								+ calendar.get(Calendar.MINUTE)
								: "" + calendar.get(Calendar.MINUTE);
						time_tv.setText(calendarHour + ":" + calendarMinute + "\n设置时间");
						tv_clock_time.setText(calendarHour + ":" + calendarMinute);

						App.getDBcApplication().updateSceduleDataTime(mMap.get(ScheduleTable.schID), calendarHour + ":" + calendarMinute, 1);
						loadData();
						adapter.notifyDataSetChanged();
						QueryAlarmData.writeAlarm(context);

						Intent intentappwidget = new Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
						Bundle extras = new Bundle();
						intentappwidget.putExtras(extras);
						getActivity().sendBroadcast(intentappwidget);

					}
				});

				if (hour == i) {
					chooseHour = text;
					textView.setTextColor(Color.WHITE);
					textView.setBackgroundResource(R.mipmap.icon_shuzi1);
				} else {
					textView.setBackgroundDrawable(null);
				}

				rela_hour.addView(textView);

				textView.setAnimation(animTranslate(centerX, centerY, x1, y1,
						textView, 200));

				hours--;
			}
		}

		private void initMinutes() {
			int minute = calendar.get(Calendar.MINUTE);
			int result = minute % 5;
			if (result != 0) {
				int division = minute / 5;
				minute = division * 5;
			}
			int minutesRadius = Utils.dipTopx(context, 140); // 设置圆半径
			for (int i = 0; i < 12; i++) {
				int dy = (int) (minutesRadius * Math.cos((Math.PI / 6.0) * i));
				int dx = (int) (minutesRadius * Math.sin((Math.PI / 6.0) * i));

				int x1 = centerX + dx;
				int y1 = centerY - dy;

				String text = minutes * 5 < 10 ? "0" + minutes * 5 : ""
						+ minutes * 5;

				TextView textView = new TextView(context);
				textView.setText(text);
				textView.setTextColor(Color.WHITE);
				textView.setTextSize(18.0f);
				textView.setGravity(Gravity.CENTER);
				textView.setLayoutParams(new LinearLayout.LayoutParams(
						LinearLayout.LayoutParams.WRAP_CONTENT,
						LinearLayout.LayoutParams.WRAP_CONTENT));
				textView.setTag(text);
				textView.setOnClickListener(new View.OnClickListener() {

					@Override
					public void onClick(View v) {
						chooseMinute = v.getTag().toString();
						chageMinutes(Integer.parseInt(chooseMinute) / 5);
						lastMinutes = Integer.parseInt(chooseMinute) / 5;
						calendar.set(Calendar.HOUR,
								Integer.parseInt(chooseHour));
						calendar.set(Calendar.MINUTE,
								Integer.parseInt(chooseMinute));
						if (grState == 0) {// 上午
							calendar.set(Calendar.AM_PM, 0);
						} else if (grState == 1) {// 下午
							calendar.set(Calendar.AM_PM, 1);
						}
						String calendarHour = calendar
								.get(Calendar.HOUR_OF_DAY) < 10 ? "0"
								+ calendar.get(Calendar.HOUR_OF_DAY) : ""
								+ calendar.get(Calendar.HOUR_OF_DAY);
						String calendarMinute = calendar.get(Calendar.MINUTE) < 10 ? "0"
								+ calendar.get(Calendar.MINUTE)
								: "" + calendar.get(Calendar.MINUTE);
						time_tv.setText(calendarHour + ":" + calendarMinute + "\n设置时间");
						tv_clock_time.setText(calendarHour + ":"
								+ calendarMinute);
						App.getDBcApplication().updateSceduleDataTime(mMap.get(ScheduleTable.schID), calendarHour + ":" + calendarMinute, 1);
						loadData();
						adapter.notifyDataSetChanged();
						QueryAlarmData.writeAlarm(context);

						Intent intentappwidget = new Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
						Bundle extras = new Bundle();
						intentappwidget.putExtras(extras);
						getActivity().sendBroadcast(intentappwidget);
					}
				});
				if (minute == Integer.parseInt(text)) {
					lastMinutes = i;
					chooseMinute = text;
					textView.setTextColor(Color.WHITE);
					textView.setBackgroundResource(R.mipmap.icon_shuzi2);
				} else {
					textView.setBackgroundDrawable(null);
				}
				rela_minutes.addView(textView);
				textView.setAnimation(animTranslate(centerX, centerY, x1, y1,
						textView, 200));

				minutes++;
			}
		}

		private void chageHour(int hours) {
			for (int i = rela_hour.getChildCount() - 1; i >= 0; i--) {
				TextView tv_hour = (TextView) rela_hour.getChildAt(i);
				if (hours == Integer.parseInt(tv_hour.getTag().toString())) {
					tv_hour.setBackgroundResource(R.mipmap.icon_shuzi1);
				} else {
					tv_hour.setBackgroundDrawable(null);
				}
			}
		}

		private void chageMinutes(int minutes) {
			TextView textView = (TextView) rela_minutes.getChildAt(lastMinutes);
			textView.setBackgroundDrawable(null);
			TextView tv_minutes = (TextView) rela_minutes.getChildAt(minutes);
			tv_minutes.setBackgroundResource(R.mipmap.icon_shuzi2);
		}


		@Override
		public void onClick(View v) {
			switch (v.getId()) {
				case R.id.dialog_tv_state:
					calendar.set(Calendar.HOUR, Integer.parseInt(chooseHour));
					calendar.set(Calendar.MINUTE, Integer.parseInt(chooseMinute));
					if (grState == 0) {// 上午
						dialog_tv_state.setText("下午");
						grState = 1;
						calendar.set(Calendar.AM_PM, grState);
					} else if (grState == 1) {// 下午
						dialog_tv_state.setText("上午");
						grState = 0;
						calendar.set(Calendar.AM_PM, grState);
					}
					dialog_tv_state.startAnimation(AnimationUtils.loadAnimation(
							context, R.anim.scale_in));
					String calendarHour = calendar.get(Calendar.HOUR_OF_DAY) < 10 ? "0"
							+ calendar.get(Calendar.HOUR_OF_DAY)
							: "" + calendar.get(Calendar.HOUR_OF_DAY);
					String calendarMinute = calendar.get(Calendar.MINUTE) < 10 ? "0"
							+ calendar.get(Calendar.MINUTE)
							: "" + calendar.get(Calendar.MINUTE);
					time_tv.setText(calendarHour + ":" + calendarMinute + "\n设置时间");
					tv_clock_time.setText(calendarHour + ":" + calendarMinute);

					App.getDBcApplication().updateSceduleDataTime(mMap.get(ScheduleTable.schID), calendarHour + ":" + calendarMinute, 1);
					loadData();
					adapter.notifyDataSetChanged();
					QueryAlarmData.writeAlarm(context);

					Intent intentappwidget1 = new Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
					Bundle extras1 = new Bundle();
					intentappwidget1.putExtras(extras1);
					getActivity().sendBroadcast(intentappwidget1);
//                    dialog.dismiss();
					break;

				case R.id.tv_clock_state:
					// isNeedPush = false;
					time_tv.setText("全天\n设置时间");
					// tv_beforetime.setText("");
					dialog.dismiss();
					App.getDBcApplication().updateSceduleDataTime(mMap.get(ScheduleTable.schID), mMap.get(ScheduleTable.schTime), 0);
					loadData();
					adapter.notifyDataSetChanged();
					QueryAlarmData.writeAlarm(context);

					Intent intentappwidget = new Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
					Bundle extras = new Bundle();
					intentappwidget.putExtras(extras);
					getActivity().sendBroadcast(intentappwidget);

//                    dialog.dismiss();
					break;

				case R.id.ll_clock:
//                    if (date_re.getVisibility() == View.VISIBLE){
//                        date_re.setVisibility(View.GONE);
//                        time_ll.setVisibility(View.VISIBLE);
//                    }else {
//                        date_re.setVisibility(View.VISIBLE);
//                        time_ll.setVisibility(View.GONE);
//                    }
					break;

				default:
					dialog.dismiss();

					break;
			}
		}

	}

	@Override
	public void onActivityResult(int requestCode, int resultCode, Intent data) {
		loadData();
		adapter.notifyDataSetChanged();
		super.onActivityResult(requestCode, resultCode, data);
	}

	private Animation animationTranslate;
	private RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(0, 0);

	// 移动的动画效果
    /*
     * TranslateAnimation(float fromXDelta, float toXDelta, float
	 * fromYDelta,float toYDelta)
	 *
	 * float fromXDelta:这个参数表示动画开始的点离当前View X坐标上的差值；
	 *
	 * float toXDelta, 这个参数表示动画结束的点离当前View X坐标上的差值；
	 *
	 * float fromYDelta, 这个参数表示动画开始的点离当前View Y坐标上的差值；
	 *
	 * float toYDelta)这个参数表示动画开始的点离当前View Y坐标上的差值；
	 */
	protected Animation animTranslate(float toX, float toY, final int x1,
									  final int y1, final TextView textView, long durationMillis) {
		animationTranslate = new TranslateAnimation(toX, toX, toY, toY);
		animationTranslate.setAnimationListener(new Animation.AnimationListener() {

			@Override
			public void onAnimationStart(Animation animation) {

			}

			@Override
			public void onAnimationRepeat(Animation animation) {

			}

			@Override
			public void onAnimationEnd(Animation animation) {
				params = new RelativeLayout.LayoutParams(
						RelativeLayout.LayoutParams.WRAP_CONTENT,
						RelativeLayout.LayoutParams.WRAP_CONTENT);
				params.setMargins(x1, y1, 0, 0);
				textView.setLayoutParams(params);
				textView.setPadding(12, 7, 12, 7);
				textView.clearAnimation();
			}
		});
		animationTranslate.setDuration(durationMillis);
		return animationTranslate;
	}

	private void initValues(int setBefore) {
		if (setBefore == 0) {
			indexti = 0;
		} else if (setBefore == 5) {
			indexti = 1;
		} else if (setBefore == 15) {
			indexti = 2;
		} else if (setBefore == 30) {
			indexti = 3;
		} else if (setBefore == 60) {
			indexti = 4;
		} else if (setBefore == 120) {
			indexti = 5;
		} else if (setBefore == 24 * 60) {
			indexti = 6;
		} else if (setBefore == 48 * 60) {
			indexti = 7;
		} else if (setBefore == 7 * 24 * 60) {
			indexti = 8;
		}
	}


	/******日历*****/
	int[] solartime = new int[25];
	boolean isLeap = false;
	boolean isRed = false;
	ArrayList<HashMap<String, String>> data;
	String today;
	int temp_day;
	int temp_month;
	int temp_year;

	int to_day;
	int to_month;
	int to_year;
	int standard_day;
	int standard_month;
	int standard_year;
	String holiday = "";
	String curDate = "";

	int sourse;//
	String dateTime = "";// 日期
	private TextView title;

	MyLinearLayout dataLinear;
	Handler handlerrili;
	LinearLayout.LayoutParams mLayoutParamss = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
			LinearLayout.LayoutParams.MATCH_PARENT);

	private void initRiliDiaLog(final TextView date_tv, final Map<String, String> mMap) {
		final Dialog dialog = new Dialog(context, R.style.dialog_translucent);
		Window window = dialog.getWindow();
		WindowManager.LayoutParams params = window.getAttributes();// 获取LayoutParams
		window.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL);
		window.setAttributes(params);// 设置生效

		LayoutInflater fac = LayoutInflater.from(context);
		View more_pop_menu = fac.inflate(R.layout.dialog_calender_rili, null);
		dialog.setCanceledOnTouchOutside(true);
		dialog.setContentView(more_pop_menu);
		params.height = ViewGroup.LayoutParams.WRAP_CONTENT;
		params.width = getActivity().getWindowManager().getDefaultDisplay().getWidth() - 30;
		dialog.show();

		curDate = dateTime;

		dataLinear = (MyLinearLayout) more_pop_menu.findViewById(R.id.datalinear);
		title = (TextView) more_pop_menu.findViewById(R.id.title);
		dataLinear.setBackgroundColor(Color.WHITE);
		handlerrili = new Handler() {
			public void handleMessage(Message msg) {
				if (msg == null) {
					return;
				}
				switch (msg.what) {
					case 0:
						if (standard_month == 1) {
							standard_month = 12;
							standard_year--;
						} else {
							standard_month--;
						}
						GenData(false, curDate);
						GenView();
						title.setText(standard_year + "年" + standard_month + "月");
						dataLinear.startAnimation(AnimationUtils.loadAnimation(context, R.anim.right_in));
						break;

					case 1:
						if (standard_month == 12) {
							standard_month = 1;
							standard_year++;
						} else {
							standard_month++;
						}
						GenData(false, curDate);
						GenView();
						title.setText(standard_year + "年" + standard_month + "月");
						dataLinear.startAnimation(AnimationUtils.loadAnimation(context, R.anim.left_in));
						break;

					case 2:
						standard_year--;
						GenData(false, curDate);
						GenView();
						title.setText(standard_year + "年" + standard_month + "月");
						dataLinear.startAnimation(AnimationUtils.loadAnimation(context, R.anim.down_in));
						break;

					case 3:
						standard_year++;
						GenData(false, curDate);
						GenView();
						title.setText(standard_year + "年" + standard_month + "月");
						dataLinear.startAnimation(AnimationUtils.loadAnimation(context, R.anim.up_in));
						break;

					case 9:
						date_tv.setText(msg.obj + "");

						dialog.dismiss();
						App.getDBcApplication().updateSceduleDataDate(mMap.get(ScheduleTable.schID), (msg.obj + "").split("\n")[0]);
						loadData();adapter.notifyDataSetChanged();
						QueryAlarmData.writeAlarm(context);

						Intent intentappwidget = new Intent(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
						Bundle extras = new Bundle();
						intentappwidget.putExtras(extras);
						getActivity().sendBroadcast(intentappwidget);
						break;

					case 11:
						Toast.makeText(context, "网络中断", Toast.LENGTH_LONG).show();
						break;

					case 12:
						Toast.makeText(context, "服务器错误", Toast.LENGTH_LONG).show();
						break;
				}
			}
		};
		dataLinear.setHandler(handlerrili);


		new LoadDataAsyncTask().execute();


	}

	class LoadDataAsyncTask extends AsyncTask<Void, Void, Void> {

		@Override
		protected Void doInBackground(Void... params) {
			return null;
		}

		@Override
		protected void onPostExecute(Void result) {
			super.onPostExecute(result);
//			dialog.dismiss();
			GenData(true, curDate);
			GenView();
		}

	}

	public ArrayList<HashMap<String, String>> GenData(boolean isfirst, String date) {
		if (!date.equals("") && isfirst) {
			data = new ArrayList<HashMap<String, String>>();
			to_year = Integer.parseInt(date.split("-")[0].toString());
			to_month = Integer.parseInt(date.split("-")[1].toString());
			to_day = Integer.parseInt(date.split("-")[2].toString());
			temp_day = to_day;
			temp_month = to_month;
			temp_year = to_year;
			standard_day = to_day;
			standard_month = to_month;
			standard_year = to_year;
			today = date;
			title.setText(standard_year + "年" + standard_month + "月");
		} else {
			if (isfirst) {
				data = new ArrayList<HashMap<String, String>>();
				Calendar c = Calendar.getInstance();
				c.setTimeInMillis(System.currentTimeMillis());
				to_year = c.get(Calendar.YEAR);
				to_month = c.get(Calendar.MONTH);
				to_day = c.get(Calendar.DAY_OF_MONTH);

				to_month++;
				temp_day = to_day;
				temp_month = to_month;
				temp_year = to_year;
				standard_day = to_day;
				standard_month = to_month;
				standard_year = to_year;

				today = to_year + "-"
						+ (to_month > 9 ? "" + to_month : "0" + to_month) + "-"
						+ (to_day > 9 ? "" + to_day : "0" + to_day);
				title.setText(standard_year + "年" + standard_month + "月");
			} else {
				data = new ArrayList<HashMap<String, String>>();
				temp_day = standard_day;
				temp_month = standard_month;
				temp_year = standard_year;

			}
		}
		HashMap<String, String> map = new HashMap<String, String>();
		map.put("day", temp_day + "");

		map.put("isMonth", "1"); // 1是本月
		String tempStrT = temp_year + "-"
				+ (temp_month > 9 ? "" + temp_month : "0" + temp_month) + "-"
				+ (temp_day > 9 ? "" + temp_day : "0" + temp_day);
		if ("".equals(StringUtils.getIsStringEqulesNull(tempStrT))) {
			tempStrT = today;
		}
		if (today.equals(tempStrT)) {
			map.put("isToday", "1"); // 1是今天
			map.put("time", today);
		} else {
			map.put("isToday", "0"); // 1是今天
			map.put("time", tempStrT);
		}
		try {
			if (CalHoliday(Integer.valueOf(temp_month
					+ (temp_day > 9 ? "" + temp_day : "0" + temp_day)))) {
				map.put("lunar", holiday);
			} else {
				map.put("lunar", CalendarChange.CalendarChange(tempStrT));
			}
			if (isRed) {
				map.put("isHoliday", "1"); // 1节日
				isRed = false;
			} else {
				map.put("isHoliday", "0"); // 1节日
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		data.add(map);
		for (int i = temp_day - 1; i > 0; i--) {
			String tempStr = temp_year + "-"
					+ (temp_month > 9 ? "" + temp_month : "0" + temp_month)
					+ "-" + (i > 9 ? "" + i : "0" + i);
			map = new HashMap<String, String>();
			map.put("day", i + "");
			map.put("time", tempStr);
			map.put("isToday", "0"); // 1是今天
			map.put("isMonth", "1"); // 1是本月
			try {
				if (CalHoliday(Integer.valueOf("" + temp_month
						+ (i > 9 ? "" + i : "0" + i)))) {
					map.put("lunar", holiday);
				} else {
					map.put("lunar", CalendarChange.CalendarChange(tempStr));
				}
				if (isRed) {
					map.put("isHoliday", "1"); // 1节日
					isRed = false;
				} else {
					map.put("isHoliday", "0"); // 1节日
				}
			} catch (Exception e) {
				e.printStackTrace();
			}
			data.add(0, map);
		}
		int te_week = calWeek(temp_year, temp_month, 1);
		if (temp_month == 1) {
			temp_year--;
			temp_month = 12;
		} else {
			temp_month--;
		}
		calLeapYear(temp_year);
		if (temp_month == 4 || temp_month == 6 || temp_month == 9
				|| temp_month == 11) {
			for (int i = 30; i > 30 - te_week; i--) {
				String tempStr = temp_year + "-"
						+ (temp_month > 9 ? "" + temp_month : "0" + temp_month)
						+ "-" + (i > 9 ? "" + i : "0" + i);
				map = new HashMap<String, String>();
				map.put("day", i + "");
				map.put("time", tempStr);
				map.put("isToday", "0"); // 是今天
				map.put("isMonth", "0"); // 1是本月
				try {
					if (CalHoliday(Integer.valueOf("" + temp_month
							+ (i > 9 ? "" + i : "0" + i)))) {
						map.put("lunar", holiday);
					} else {
						map.put("lunar", CalendarChange.CalendarChange(tempStr));
					}
					if (isRed) {
						map.put("isHoliday", "1"); // 1节日
						isRed = false;
					} else {
						map.put("isHoliday", "0"); // 1节日
					}
				} catch (Exception e) {
					e.printStackTrace();
				}
				data.add(0, map);
			}
		} else if (temp_month == 2) {
			if (isLeap) {
				for (int i = 29; i > 29 - te_week; i--) {
					String tempStr = temp_year
							+ "-"
							+ (temp_month > 9 ? "" + temp_month : "0"
							+ temp_month) + "-"
							+ (i > 9 ? "" + i : "0" + i);
					map = new HashMap<String, String>();
					map.put("day", i + "");
					map.put("time", tempStr);
					map.put("isToday", "0"); // 1是今天
					map.put("isMonth", "0"); // 1是本月
					try {
						if (CalHoliday(Integer.valueOf("" + temp_month
								+ (i > 9 ? "" + i : "0" + i)))) {
							map.put("lunar", holiday);
						} else {
							map.put("lunar",
									CalendarChange.CalendarChange(tempStr));
						}
						if (isRed) {
							map.put("isHoliday", "1"); // 1节日
							isRed = false;
						} else {
							map.put("isHoliday", "0"); // 1节日
						}
					} catch (Exception e) {
						e.printStackTrace();
					}
					data.add(0, map);
				}
			} else {
				for (int i = 28; i > 28 - te_week; i--) {
					String tempStr = temp_year
							+ "-"
							+ (temp_month > 9 ? "" + temp_month : "0"
							+ temp_month) + "-"
							+ (i > 9 ? "" + i : "0" + i);
					map = new HashMap<String, String>();
					map.put("day", i + "");
					map.put("time", tempStr);
					map.put("isToday", "0"); // 1是今天
					map.put("isMonth", "0"); // 1是本月
					try {
						if (CalHoliday(Integer.valueOf("" + temp_month
								+ (i > 9 ? "" + i : "0" + i)))) {
							map.put("lunar", holiday);
						} else {
							map.put("lunar",
									CalendarChange.CalendarChange(tempStr));
						}
						if (isRed) {
							map.put("isHoliday", "1"); // 1节日
							isRed = false;
						} else {
							map.put("isHoliday", "0"); // 1节日
						}
					} catch (Exception e) {
						e.printStackTrace();
					}
					data.add(0, map);
				}
			}
		} else {
			for (int i = 31; i > 31 - te_week; i--) {
				String tempStr = temp_year + "-"
						+ (temp_month > 9 ? "" + temp_month : "0" + temp_month)
						+ "-" + (i > 9 ? "" + i : "0" + i);
				map = new HashMap<String, String>();
				map.put("day", i + "");
				map.put("time", tempStr);
				map.put("isToday", "0"); // 1是今天
				map.put("isMonth", "0"); // 1是本月
				try {
					if (CalHoliday(Integer.valueOf("" + temp_month
							+ (i > 9 ? "" + i : "0" + i)))) {
						map.put("lunar", holiday);
					} else {
						map.put("lunar", CalendarChange.CalendarChange(tempStr));
					}
					if (isRed) {
						map.put("isHoliday", "1"); // 1节日
						isRed = false;
					} else {
						map.put("isHoliday", "0"); // 1节日
					}
				} catch (Exception e) {
					e.printStackTrace();
				}
				data.add(0, map);
			}
		}
		if (temp_month == 12) {
			temp_year++;
			temp_month = 1;
		} else {
			temp_month = temp_month + 1;
		}
		calLeapYear(temp_year);
		if (temp_month == 4 || temp_month == 6 || temp_month == 9
				|| temp_month == 11) {
			for (int i = to_day + 1; i <= 30; i++) {
				String tempStr = temp_year + "-"
						+ (temp_month > 9 ? "" + temp_month : "0" + temp_month)
						+ "-" + (i > 9 ? "" + i : "0" + i);
				map = new HashMap<String, String>();
				map.put("day", i + "");
				map.put("time", tempStr);
				map.put("isToday", "0"); // 1是今天
				map.put("isMonth", "1"); // 1是本月
				try {
					if (CalHoliday(Integer.valueOf("" + temp_month
							+ (i > 9 ? "" + i : "0" + i)))) {
						map.put("lunar", holiday);
					} else {
						map.put("lunar", CalendarChange.CalendarChange(tempStr));
					}
					if (isRed) {
						map.put("isHoliday", "1"); // 1节日
						isRed = false;
					} else {
						map.put("isHoliday", "0"); // 1节日
					}
				} catch (Exception e) {
					e.printStackTrace();
				}
				data.add(map);
			}
		} else if (temp_month == 2) {
			if (isLeap) {
				for (int i = to_day + 1; i <= 29; i++) {
					String tempStr = temp_year
							+ "-"
							+ (temp_month > 9 ? "" + temp_month : "0"
							+ temp_month) + "-"
							+ (i > 9 ? "" + i : "0" + i);
					map = new HashMap<String, String>();
					map.put("day", i + "");
					map.put("time", tempStr);
					map.put("isToday", "0"); // 是今天
					map.put("isMonth", "1"); // 1是本月
					try {
						if (CalHoliday(Integer.valueOf("" + temp_month
								+ (i > 9 ? "" + i : "0" + i)))) {
							map.put("lunar", holiday);
						} else {
							map.put("lunar",
									CalendarChange.CalendarChange(tempStr));
						}
						if (isRed) {
							map.put("isHoliday", "1"); // 1节日
							isRed = false;
						} else {
							map.put("isHoliday", "0"); // 1节日
						}
					} catch (Exception e) {
						e.printStackTrace();
					}
					data.add(map);
				}
			} else {
				for (int i = to_day + 1; i <= 28; i++) {
					String tempStr = temp_year
							+ "-"
							+ (temp_month > 9 ? "" + temp_month : "0"
							+ temp_month) + "-"
							+ (i > 9 ? "" + i : "0" + to_day);
					map = new HashMap<String, String>();
					map.put("day", i + "");
					map.put("time", tempStr);
					map.put("isToday", "0"); // 是今天
					map.put("isMonth", "1"); // 1是本月
					try {
						if (CalHoliday(Integer.valueOf("" + temp_month
								+ (i > 9 ? "" + i : "0" + i)))) {
							map.put("lunar", holiday);
						} else {
							map.put("lunar",
									CalendarChange.CalendarChange(tempStr));
						}
						if (isRed) {
							map.put("isHoliday", "1"); // 1节日
							isRed = false;
						} else {
							map.put("isHoliday", "0"); // 1节日
						}
					} catch (Exception e) {
						e.printStackTrace();
					}
					data.add(map);
				}
			}
		} else {
			for (int i = to_day + 1; i <= 31; i++) {
				String tempStr = temp_year + "-"
						+ (temp_month > 9 ? "" + temp_month : "0" + temp_month)
						+ "-" + (i > 9 ? "" + i : "0" + i);
				map = new HashMap<String, String>();
				map.put("day", i + "");
				map.put("time", tempStr);
				map.put("isToday", "0"); // 是今天
				map.put("isMonth", "1"); // 1是本月
				try {
					if (CalHoliday(Integer.valueOf("" + temp_month
							+ (i > 9 ? "" + i : "0" + i)))) {
						map.put("lunar", holiday);
					} else {
						map.put("lunar", CalendarChange.CalendarChange(tempStr));
					}
					if (isRed) {
						map.put("isHoliday", "1"); // 1节日
						isRed = false;
					} else {
						map.put("isHoliday", "0"); // 1节日
					}
				} catch (Exception e) {
					e.printStackTrace();
				}
				data.add(map);
			}
		}
		if (temp_month >= 12) {
			temp_year++;
			temp_month = 1;
		} else {
			temp_month++;
		}
		int mm = data.size();
		for (int i = 1; i <= 42 - mm; i++) {
			String tempStr = temp_year + "-"
					+ (temp_month > 9 ? "" + temp_month : "0" + temp_month)
					+ "-" + (i > 9 ? "" + i : "0" + i);
			map = new HashMap<String, String>();
			map.put("day", i + "");
			map.put("time", tempStr);
			map.put("isToday", "0"); // 是今天
			map.put("isMonth", "0"); // 1是本月
			try {
				if (CalHoliday(Integer.valueOf("" + temp_month
						+ (i > 9 ? "" + i : "0" + i)))) {
					map.put("lunar", holiday);
				} else {
					map.put("lunar", CalendarChange.CalendarChange(tempStr));
				}
				if (isRed) {
					map.put("isHoliday", "1"); // 1节日
					isRed = false;
				} else {
					map.put("isHoliday", "0"); // 1节日
				}
			} catch (Exception e) {
				e.printStackTrace();
			}
			data.add(map);
		}
		return data;
	}

	public boolean CalHoliday(int t) {
		boolean is = false;
		switch (t / 100) {
			case 2:
				if (t == solartime[0]) {
					holiday = "立春";
					is = true;
				} else if (t == solartime[1]) {
					holiday = "雨水";
					is = true;
				}
				break;
			case 3:
				if (t == solartime[2]) {
					holiday = "惊蛰";
					is = true;
				} else if (t == solartime[3]) {
					holiday = "春分";
					is = true;
				}
				break;
			case 4:
				if (t == solartime[4]) {
					holiday = "清明";
					is = true;
				} else if (t == solartime[5]) {
					holiday = "谷雨";
					is = true;
				}
				break;
			case 5:
				if (t == solartime[6]) {
					holiday = "立夏";
					is = true;
				} else if (t == solartime[7]) {
					holiday = "小满";
					is = true;
				}
				break;
			case 6:
				if (t == solartime[8]) {
					holiday = "芒种";
					is = true;
				} else if (t == solartime[9]) {
					holiday = "夏至";
					is = true;
				}
				break;
			case 7:
				if (t == solartime[10]) {
					holiday = "小暑";
					is = true;
				} else if (t == solartime[11]) {
					holiday = "大暑";
					is = true;
				}
				break;
			case 8:
				if (t == solartime[12]) {
					holiday = "立秋";
					is = true;
				} else if (t == solartime[13]) {
					holiday = "处暑";
					is = true;
				}
				break;
			case 9:
				if (t == solartime[14]) {
					holiday = "白露";
					is = true;
				} else if (t == solartime[15]) {
					holiday = "秋分";
					is = true;
				}
				break;
			case 10:
				if (t == solartime[16]) {
					holiday = "寒露";
					is = true;
				} else if (t == solartime[17]) {
					holiday = "霜降";
					is = true;
				}
				break;
			case 11:
				if (t == solartime[18]) {
					holiday = "立冬";
					is = true;
				} else if (t == solartime[19]) {
					holiday = "小雪";
					is = true;
				}
				break;
			case 12:
				if (t == solartime[20]) {
					holiday = "大雪";
					is = true;
				} else if (t == solartime[21]) {
					holiday = "冬至";
					is = true;
				}
				break;
			case 1:
				if (t == solartime[22]) {
					holiday = "小寒";
					is = true;
				} else if (t == solartime[23]) {
					holiday = "大寒";
					is = true;
				}
				break;
		}
		switch (t) {
			case 101:
				holiday = "元旦";
				isRed = true;
				is = true;
				break;
			case 214:
				holiday = "情人节";
				is = true;
				break;
			case 308:
				holiday = "妇女节";
				is = true;
				break;
			case 312:
				holiday = "植树节";
				is = true;
				break;
			case 315:
				holiday = "消费日";
				is = true;
				break;
			case 401:
				holiday = "愚人节";
				is = true;
				break;
			// case 407:
			// holiday="卫生日";
			// is=true;
			// break;
			case 501:
				holiday = "劳动节";
				is = true;
				break;
			case 504:
				holiday = "青年节";
				is = true;
				break;
			// case 512:
			// holiday="护士节";
			// is=true;
			// break;
			// case 513:
			// holiday="助残日";
			// is=true;
			// break;

			case 601:
				holiday = "儿童节";
				is = true;
				break;
			case 605:
				holiday = "世界环境日";
				is = true;
				break;
			case 701:
				holiday = "建党节";
				is = true;
				break;
			case 801:
				holiday = "建军节";
				is = true;
				break;
			case 910:
				holiday = "教师节";
				is = true;
				break;
			case 1001:
				holiday = "国庆节";
				is = true;
				break;
			case 1225:
				holiday = "圣诞节";
				is = true;
				break;
			default:
				// is=false;
				break;
		}

		return is;
	}

	@SuppressWarnings("deprecation")
	public void GenView() {
		dataLinear.removeAllViews();
		mLayoutParamss.weight = 1;
		LayoutInflater lif = LayoutInflater.from(context);
		LinearLayout temp = new LinearLayout(context);
		int size = data.size();
		for (int i = 0; i < size; i++) {
			View convertView = lif.inflate(R.layout.gritem, null);
			TextView time = (TextView) convertView.findViewById(R.id.time);
			TextView lunar = (TextView) convertView.findViewById(R.id.lunar);
			TextView fraction = (TextView) convertView.findViewById(R.id.fraction);
			LinearLayout itemroot = (LinearLayout) convertView.findViewById(R.id.itemroot);
			HashMap<String, String> map = data.get(i);
			if ((i + 1) < size) {
				HashMap<String, String> map2 = data.get(i + 1);
				if (map2.get("lunar").equals("春节")) {
					map.put("lunar", "除夕");
				}
			}
			if (map.get("isMonth").equals("1"))// 1是本月
			{
				itemroot.setBackgroundDrawable(getResources().getDrawable(R.drawable.bg_riliactivity));
				if (map.get("isToday").equals("1"))// 1是今天
				{
					time.setTextColor(getResources().getColor(R.color.sunday_txt));
					lunar.setTextColor(getResources().getColor(R.color.sunday_txt));
					itemroot.setBackgroundDrawable(getResources().getDrawable(R.drawable.bg_riliactivity_jintian));
				} else {
					itemroot.setBackgroundDrawable(getResources().getDrawable(R.drawable.bg_riliactivity));
				}
				int m = (i + 1) % 7;
				if (m == 1 || m == 0) {
					time.setTextColor(Color.rgb(50, 79, 133));
				}
				if (map.get("isHoliday").equals("1")) // 节日
				{
					time.setTextColor(Color.RED);
				}
				itemroot.setTag(R.id.calendar_index, "1");//0其他,1是本月
			} else {
				time.setTextColor(getResources().getColor(R.color.othermonth_txt));
				lunar.setTextColor(getResources().getColor(R.color.othermonth_txt));
				itemroot.setBackgroundDrawable(getResources().getDrawable(R.drawable.bg_riliactivity));
				itemroot.setTag(R.id.calendar_index, "0");
			}
			String day = map.get("day");
			fraction.setText(map.get("fraction"));
			time.setText(day);
			lunar.setText(map.get("lunar"));
			itemroot.setTag(day);
			itemroot.setOnClickListener(new View.OnClickListener() {
				@Override
				public void onClick(View v) {
					String day = v.getTag().toString();
					// 0其他,1是本月
					String calendar_index = v.getTag(R.id.calendar_index)
							.toString();
					if ("1".equals(calendar_index)) {
						Intent intent = null;
						String dateTime = Integer.toString(standard_year)
								+ "-"
								+ (standard_month > 9 ? "" + standard_month
								: "0" + standard_month) + "-"
								+ (Integer.parseInt(day) > 9 ? day : "0" + day);
						Message message = new Message();
						message.what = 9;
						message.obj = dateTime + "\n更换日期";
						handlerrili.sendMessage(message);
					}
				}
			});
			if ((i + 1) % 7 != 0) {
				temp.addView(convertView, mLayoutParamss);
			} else {
				if (i != 0) {
					temp.addView(convertView, mLayoutParamss);
					dataLinear.addView(temp, mLayoutParamss);
					temp = new LinearLayout(context);
				}
			}
		}
	}

	/*
     * 基姆拉尔森计算公式 QgW4jIbx W= (d+2*m+3*(m+1)/5+y+y/4-y/100+y/400) mod 7 /
     *
     * d 天 m 月 y 年 1月2月换算为去年的13 14月计算
     *
     * 基姆拉尔森计算公式的C#的实现 %NfbgJcL_ //y：年，m：月，d：日。在参数都只传入相应的整数
     */
	private int calWeek(int y, int m, int d) {
		int a = 7; // 用来保存计算得到的星期几的整数 Dz>v;%$S-
		if ((m == 1) || (m == 2))// 如果是一月或二月进行换算 uWKc .
		{
			m += 12;
			y--;
		}
		a = (d + 2 * m + 3 * (m + 1) / 5 + y + y / 4 - y / 100 + y / 400) % 7; // 得到的星期几的整数
		// 
		// 7ehs+GI
		a++;
		if (a == 7) {
			a = 0;
		}
		return a;
	}

	public void calLeapYear(int i) {
		if (i % 100 == 0) {
			if (i % 400 == 0) {
				isLeap = true;
			} else {
				isLeap = false;
			}
		} else {
			if (i % 4 == 0) {
				isLeap = true;
			} else {
				isLeap = false;
			}
		}
	}

	private void initBeforeDiaLog(TextView tixing_tv, Map<String, String> mMap) {
		Dialog dialog = new Dialog(context, R.style.dialog_translucent);
		Window window = dialog.getWindow();
		WindowManager.LayoutParams params = window.getAttributes();// 获取LayoutParams
		window.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL);
		window.setAttributes(params);// 设置生效

		LayoutInflater fac = LayoutInflater.from(context);
		View more_pop_menu = fac.inflate(R.layout.dialog_naozhongtiqian, null);
		dialog.setCanceledOnTouchOutside(true);
		dialog.setContentView(more_pop_menu);
		params.height = ViewGroup.LayoutParams.WRAP_CONTENT;
		params.width = getActivity().getWindowManager().getDefaultDisplay().getWidth() - 30;
		dialog.show();
		new MyBeforeOnClick(dialog, more_pop_menu, tixing_tv, mMap);
	}

	Map<Integer, Boolean> map = new HashMap<Integer, Boolean>();
	private LinearLayout ll;
	private TextView tixingcishu_tv;
	private TextView year_tv;
	private TextView HHmmtime_tv;

	private LinearLayout tixing_ll;
	private TextView tixingcishu_tv1;
	private TextView year_tv1;
	private TextView time_tv1;

	int indexti = 0;
	GridBeforeAdapter adapterti = null;

	class MyBeforeOnClick implements View.OnClickListener {

		private View view;
		private Dialog dialog;
		private GridView before_gridview;
		private LinearLayout detail_close;
		private TextView tixing_tv;

		private String[] befStrings;

		int height;

		boolean beforeFag;
		Map<String, String> mMap;

		public MyBeforeOnClick(Dialog dialog, View view, TextView tixing_tv, Map<String, String> mMap) {
			this.dialog = dialog;
			this.view = view;
			this.mMap = mMap;
			this.tixing_tv = tixing_tv;
			initview();
			initdata();
		}

		private void initview() {
			detail_close = (LinearLayout) view.findViewById(R.id.detail_close);
			ll = (LinearLayout) view.findViewById(R.id.ll);
			tixingcishu_tv = (TextView) view.findViewById(R.id.tixingcishu_tv);
			year_tv = (TextView) view.findViewById(R.id.year_tv);
			HHmmtime_tv = (TextView) view.findViewById(R.id.time_tv);
			tixing_ll = (LinearLayout) view.findViewById(R.id.tixing_ll);
			tixingcishu_tv1 = (TextView) view
					.findViewById(R.id.tixingcishu_tv1);
			year_tv1 = (TextView) view.findViewById(R.id.year_tv1);
			time_tv1 = (TextView) view.findViewById(R.id.time_tv1);
			before_gridview = (GridView) view
					.findViewById(R.id.before_gridview);
			height = Utils.dipTopx(context, 100);
			befStrings = context.getResources().getStringArray(R.array.before_time);
			tixingcishu_tv.setText("1");

			detail_close.setOnClickListener(this);
		}

		private void initdata() {
			if (!"".equals(mMap.get(ScheduleTable.schID)) && mMap.get(ScheduleTable.schID) != null) {
				if (1 == isAlarm || 3 == isAlarm) {
					map.put(0, true);
				} else {
					map.put(0, false);
				}
				String beforeStr = "";
				if (tixing_tv.getText().toString().equals("准时提醒")) {
					indexti = 0;
				} else if (tixing_tv.getText().toString().equals("提前5分钟")) {
					beforeStr = "5分钟";
					indexti = 1;
				} else if (tixing_tv.getText().toString().equals("提前15分钟")) {
					beforeStr = "15分钟";
					indexti = 2;
				} else if (tixing_tv.getText().toString().equals("提前30分钟")) {
					beforeStr = "30分钟";
					indexti = 3;
				} else if (tixing_tv.getText().toString().equals("提前1小时")) {
					beforeStr = "1小时";
					indexti = 4;
				} else if (tixing_tv.getText().toString().equals("提前2小时")) {
					beforeStr = "2小时";
					indexti = 5;
				} else if (tixing_tv.getText().toString().equals("提前1天")) {
					beforeStr = "1天";
					indexti = 6;
				} else if (tixing_tv.getText().toString().equals("提前2天")) {
					beforeStr = "2天";
					indexti = 7;
				} else if (tixing_tv.getText().toString().equals("提前1周")) {
					beforeStr = "1周";
					indexti = 8;
				} else if (tixing_tv.getText().toString().equals("准时提醒\n提前5分钟")) {
					beforeStr = "5分钟";
					indexti = 1;
				} else if (tixing_tv.getText().toString().equals("准时提醒\n提前15分钟")) {
					beforeStr = "15分钟";
					indexti = 2;
				} else if (tixing_tv.getText().toString().equals("准时提醒\n提前30分钟")) {
					beforeStr = "30分钟";
					indexti = 3;
				} else if (tixing_tv.getText().toString().equals("准时提醒\n提前1小时")) {
					beforeStr = "1小时";
					indexti = 4;
				} else if (tixing_tv.getText().toString().equals("准时提醒\n提前2小时")) {
					beforeStr = "2小时";
					indexti = 5;
				} else if (tixing_tv.getText().toString().equals("准时提醒\n提前1天")) {
					beforeStr = "1天";
					indexti = 6;
				} else if (tixing_tv.getText().toString().equals("准时提醒\n提前2天")) {
					beforeStr = "2天";
					indexti = 7;
				} else if (tixing_tv.getText().toString().equals("准时提醒\n提前1周")) {
					beforeStr = "1周";
					indexti = 8;
				}
				map.put(indexti, true);
				adapterti = new GridBeforeAdapter(context, befStrings, height,
						indexti, tixing_tv, mMap);
				before_gridview.setAdapter(adapterti);

			} else {
				map.put(0, true);
				String beforeStr = "";
				if (tixing_tv.getText().toString().equals("准时提醒")) {
					indexti = 0;
				} else if (tixing_tv.getText().toString().equals("提前5分钟")) {
					beforeStr = "5分钟";
					indexti = 1;
				} else if (tixing_tv.getText().toString().equals("提前15分钟")) {
					beforeStr = "15分钟";
					indexti = 2;
				} else if (tixing_tv.getText().toString().equals("提前30分钟")) {
					beforeStr = "30分钟";
					indexti = 3;
				} else if (tixing_tv.getText().toString().equals("提前1小时")) {
					beforeStr = "1小时";
					indexti = 4;
				} else if (tixing_tv.getText().toString().equals("提前2小时")) {
					beforeStr = "2小时";
					indexti = 5;
				} else if (tixing_tv.getText().toString().equals("提前1天")) {
					beforeStr = "1天";
					indexti = 6;
				} else if (tixing_tv.getText().toString().equals("提前2天")) {
					beforeStr = "2天";
					indexti = 7;
				} else if (tixing_tv.getText().toString().equals("提前1周")) {
					beforeStr = "1周";
					indexti = 8;
				} else if (tixing_tv.getText().toString().equals("准时提醒\n提前5分钟")) {
					beforeStr = "5分钟";
					indexti = 1;
				} else if (tixing_tv.getText().toString().equals("准时提醒\n提前15分钟")) {
					beforeStr = "15分钟";
					indexti = 2;
				} else if (tixing_tv.getText().toString().equals("准时提醒\n提前30分钟")) {
					beforeStr = "30分钟";
					indexti = 3;
				} else if (tixing_tv.getText().toString().equals("准时提醒\n提前1小时")) {
					beforeStr = "1小时";
					indexti = 4;
				} else if (tixing_tv.getText().toString().equals("准时提醒\n提前2小时")) {
					beforeStr = "2小时";
					indexti = 5;
				} else if (tixing_tv.getText().toString().equals("准时提醒\n提前1天")) {
					beforeStr = "1天";
					indexti = 6;
				} else if (tixing_tv.getText().toString().equals("准时提醒\n提前2天")) {
					beforeStr = "2天";
					indexti = 7;
				} else if (tixing_tv.getText().toString().equals("准时提醒\n提前1周")) {
					beforeStr = "1周";
					indexti = 8;
				}
				map.put(indexti, true);
				adapterti = new GridBeforeAdapter(context, befStrings, height,
						indexti, tixing_tv, mMap);
				before_gridview.setAdapter(adapterti);
			}
		}

		@Override
		public void onClick(View v) {
			Animation translateIn0 = new TranslateAnimation(-view.getWidth(),
					0, 0, 0);
			Animation translateIn1 = new TranslateAnimation(view.getWidth(), 0,
					0, 0);
			translateIn0.setDuration(400);
			translateIn1.setDuration(400);
			switch (v.getId()) {
				case R.id.detail_close:
					dialog.dismiss();
					break;
				default:
					break;
			}
		}
	}

	private void initMap() {
		for (int i = 1; i < 9; i++) {
			if (i == indexti) {
				map.put(i, true);
			} else {
				map.put(i, false);
			}
		}
	}

	private void initMap1() {
		for (int i = 1; i < 9; i++) {
			map.put(i, false);
		}
	}

	int isAlarm = 0;

	public class GridBeforeAdapter extends BaseAdapter {

		private Context context;
		private String[] beforeTime;
		private int height;
		private int lastIndex;
		String str = "准时提醒";
		TextView tixing;
		Map<String, String> mMap;

		public GridBeforeAdapter(Context context, String[] beforeTime,
								 int height, int lastIndex, TextView tixing, Map<String, String> mMap) {
			this.context = context;
			this.beforeTime = beforeTime;
			this.height = height;
			this.lastIndex = lastIndex;
			this.tixing = tixing;
			this.mMap = mMap;
			initMap();
		}

		@Override
		public int getCount() {
			return beforeTime.length;
		}

		@Override
		public Object getItem(int position) {
			return beforeTime[position];
		}

		@Override
		public long getItemId(int position) {
			return position;
		}

		public String[] getBeforeTime() {
			return beforeTime;
		}

		@Override
		public View getView(final int position, View convertView,
							ViewGroup parent) {
			View view = convertView;
			GridBeforeAdapter.ViewWapper viewWapper = null;
			if (view == null) {
				view = LayoutInflater.from(context).inflate(
						R.layout.adapter_grid_before_item, null);
				viewWapper = new GridBeforeAdapter.ViewWapper(view);
				view.setTag(viewWapper);
			} else {
				viewWapper = (GridBeforeAdapter.ViewWapper) view.getTag();
			}
			LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
					LinearLayout.LayoutParams.MATCH_PARENT, height);
			LinearLayout before_ll = viewWapper.getBeforLL();
			before_ll.setLayoutParams(params);

			TextView before_tv = viewWapper.getBeforTime();
			TextView before_tv_state = viewWapper.getBeforState();
			String beforTime = beforeTime[position];
			if (beforTime.equals(str)) {
				before_tv.setText(beforTime);
				before_tv.setTextSize(15);
			} else {
				before_tv.setText(beforTime.split("-")[0]);
				before_tv_state.setText(beforTime.split("-")[1]);
			}


			before_ll.setOnClickListener(new View.OnClickListener() {
				@Override
				public void onClick(View v) {

					if (position == 0) {
						if (map.get(0)) {
							map.put(position, false);
						} else {
							map.put(position, true);
						}
					} else {
						if (position == lastIndex) {
							if (map.get(position)) {
								map.put(position, false);
							} else {
								map.put(position, true);
							}
						} else {
							initMap1();
							map.put(position, true);
						}

						lastIndex = position;
					}

					adapterti.notifyDataSetChanged();

					int before = 0;
					if (map.get(0)) {
						before = 0;
					}
					if (map.get(1)) {
						before = 5;
					} else if (map.get(2)) {
						before = 15;
					} else if (map.get(3)) {
						before = 30;
					} else if (map.get(4)) {
						before = 60;
					} else if (map.get(5)) {
						before = 120;
					} else if (map.get(6)) {
						before = 24 * 60;
					} else if (map.get(7)) {
						before = 48 * 60;
					} else if (map.get(8)) {
						before = 7 * 24 * 60;
					}

					int select = 0;
					for (int i = 0; i < beforeTime.length; i++) {
						if (map.get(i)) {
							select++;
						}
					}
					if (position == 0) {
						if (map.get(0)) {
							if (select == 1) {
								App.getDBcApplication().updateSceduleDataTiQianTime(Integer.valueOf(mMap.get(ScheduleTable.schID)), 0, 1);
							} else if (select == 2) {
								App.getDBcApplication().updateSceduleDataTiQianTime(Integer.valueOf(mMap.get(ScheduleTable.schID)), before, 3);
							}
						} else {
							if (select == 1) {
								App.getDBcApplication().updateSceduleDataTiQianTime(Integer.valueOf(mMap.get(ScheduleTable.schID)), before, 2);
							}
						}
					} else {
						if (map.get(position)) {
							if (select == 1) {
								App.getDBcApplication().updateSceduleDataTiQianTime(Integer.valueOf(mMap.get(ScheduleTable.schID)), before, 2);
							} else if (select == 2) {
								App.getDBcApplication().updateSceduleDataTiQianTime(Integer.valueOf(mMap.get(ScheduleTable.schID)), before, 3);
							}
						} else {
							if (select == 1) {
								App.getDBcApplication().updateSceduleDataTiQianTime(Integer.valueOf(mMap.get(ScheduleTable.schID)), 0, 1);
							}
						}
					}

					loadData();adapter.notifyDataSetChanged();
					QueryAlarmData.writeAlarm(context);

				}
			});

			int select = 0;
			for (int i = 0; i < beforeTime.length; i++) {
				if (map.get(i)) {
					select++;
				} else {
					tixing_ll.setVisibility(View.GONE);
				}
			}
			if (position == 0) {
				if (map.get(position)) {
					before_ll.setBackgroundColor(getResources().getColor(
							R.color.sunday_txt));
					before_tv.setTextColor(getResources().getColor(
							R.color.white));

				} else {
					before_ll.setBackgroundColor(getResources().getColor(
							R.color.choosedate));
					before_tv.setTextColor(getResources().getColor(
							R.color.gongkai_txt));
				}
			} else {
				if (map.get(position)) {
					before_ll.setBackgroundColor(getResources().getColor(
							R.color.mingtian_color));
					before_tv.setTextColor(getResources().getColor(
							R.color.white));
					before_tv_state.setTextColor(getResources().getColor(
							R.color.white));
				} else {
					before_ll.setBackgroundColor(getResources().getColor(
							R.color.choosedate));
					before_tv.setTextColor(getResources().getColor(
							R.color.gongkai_txt));
					before_tv_state.setTextColor(getResources().getColor(
							R.color.gongkai_txt));
				}
			}


			String selecttime = "";
			if ("全天".equals(mMap.get(ScheduleTable.schTime))) {
				selecttime = sharedPrefUtil.getString(context, ShareFile.USERFILE,
						ShareFile.ALLTIME, "08:58");
			} else {
				selecttime = mMap.get(ScheduleTable.schTime);
			}
			if (select == 1) {
				ll.setVisibility(View.VISIBLE);
				tixing_ll.setVisibility(View.GONE);
				if (map.get(0)) {
					tixing.setText(str);
					isAlarm = 1;
					String retStrFormatNowDate = DateUtil.formatDate(DateUtil
							.parseDate(mMap.get(ScheduleTable.schDate)));
					year_tv.setText(retStrFormatNowDate);
					HHmmtime_tv.setText(selecttime);
				} else {
					if (map.get(position)) {
						isAlarm = 2;
						if ("5-分钟".equals(beforTime)) {
							tixing.setText("提前5分钟");
						} else if ("15-分钟".equals(beforTime)) {
							tixing.setText("提前15分钟");
						} else if ("30-分钟".equals(beforTime)) {
							tixing.setText("提前30分钟");
						} else if ("1-小时".equals(beforTime)) {
							tixing.setText("提前1小时");
						} else if ("2-小时".equals(beforTime)) {
							tixing.setText("提前2小时");
						} else if ("1-天".equals(beforTime)) {
							tixing.setText("提前1天");
						} else if ("2-天".equals(beforTime)) {
							tixing.setText("提前2天");
						} else if ("1-周".equals(beforTime)) {
							tixing.setText("提前1周");
						}
						// Date nowTime = new
						// Date(System.currentTimeMillis()
						// - before * 60 * 1000);
						String retStrFormatNowDate = DateUtil
								.formatDateTime(DateUtil
										.parseDateTime(mMap.get(ScheduleTable.schDate) + " " + selecttime));
						year_tv.setText(retStrFormatNowDate.substring(0, 10));
						HHmmtime_tv.setText(retStrFormatNowDate.substring(11,
								16));
					}
				}
			} else if (select == 2) {
				ll.setVisibility(View.VISIBLE);
				tixing_ll.setVisibility(View.VISIBLE);
				isAlarm = 3;
				if (map.get(position)) {
					if ("5-分钟".equals(beforTime)) {
						tixing.setText(str + "\n提前5分钟");
					} else if ("15-分钟".equals(beforTime)) {
						tixing.setText(str + "\n提前15分钟");
					} else if ("30-分钟".equals(beforTime)) {
						tixing.setText(str + "\n提前30分钟");
					} else if ("1-小时".equals(beforTime)) {
						tixing.setText(str + "\n提前1小时");
					} else if ("2-小时".equals(beforTime)) {
						tixing.setText(str + "\n提前2小时");
					} else if ("1-天".equals(beforTime)) {
						tixing.setText(str + "\n提前1天");
					} else if ("2-天".equals(beforTime)) {
						tixing.setText(str + "\n提前2天");
					} else if ("1-周".equals(beforTime)) {
						tixing.setText(str + "\n提前1周");
					}
					int number = 0;
					if (str.equals(beforTime)) {
						number = 0;
					} else if ("5-分钟".equals(beforTime)) {
						number = 5;
					} else if ("15-分钟".equals(beforTime)) {
						number = 15;
					} else if ("30-分钟".equals(beforTime)) {
						number = 30;
					} else if ("1-小时".equals(beforTime)) {
						number = 60;
					} else if ("2-小时".equals(beforTime)) {
						number = 120;
					} else if ("1-天".equals(beforTime)) {
						number = 24 * 60;
					} else if ("2-天".equals(beforTime)) {
						number = 48 * 60;
					} else if ("1-周".equals(beforTime)) {
						number = 7 * 24 * 60;
					}
					if (number != 0) {
						String beforenowtime = DateUtil.formatDateTime(DateUtil
								.parseDateTime(mMap.get(ScheduleTable.schDate) + " " + selecttime));
						Date nowtime = new Date(DateUtil.parseDateTime(
								beforenowtime).getTime()
								- number * 60 * 1000);
						String retStrFormatNowDate = DateUtil
								.formatDateTime(nowtime);
						year_tv.setText(retStrFormatNowDate.substring(0, 10));
						HHmmtime_tv.setText(retStrFormatNowDate.substring(11,
								16));
						year_tv1.setText(beforenowtime.substring(0, 10));
						time_tv1.setText(beforenowtime.substring(11, 16));
					}
				}
			} else {
				map.put(0, true);
				ll.setVisibility(View.VISIBLE);
				tixing_ll.setVisibility(View.GONE);
				tixing.setText(str);
			}
			return view;
		}

		class ViewWapper {

			private View view;
			private LinearLayout before_ll;
			private TextView before_tv;
			private TextView before_state;

			private ViewWapper(View view) {
				this.view = view;
			}

			private LinearLayout getBeforLL() {
				if (before_ll == null) {
					before_ll = (LinearLayout) view
							.findViewById(R.id.before_ll);
				}
				return before_ll;
			}

			private TextView getBeforTime() {
				if (before_tv == null) {
					before_tv = (TextView) view.findViewById(R.id.before_tv);
				}
				return before_tv;
			}

			private TextView getBeforState() {
				if (before_state == null) {
					before_state = (TextView) view
							.findViewById(R.id.before_state);
				}
				return before_state;
			}
		}
	}

	class ViewAdapter extends PagerAdapter {
		private List<View> viewList;//数据源

		public ViewAdapter(List<View> viewList) {
			this.viewList = viewList;
		}

		@Override
		public int getCount() {
			return viewList.size();
		}

		@Override
		public boolean isViewFromObject(View view, Object object) {
			return view == object;
		}

		@Override
		public Object instantiateItem(ViewGroup container, int position) {
			container.addView(viewList.get(position));
			return viewList.get(position);
		}
	}

	@SuppressWarnings("deprecation")
//	private void dialogDetailOnClick(Map<String, String> mMap, int position) {
//		Dialog dialog = new Dialog(context, R.style.dialog_translucent);
//		Window window = dialog.getWindow();
//		android.view.WindowManager.LayoutParams params = window.getAttributes();// 获取LayoutParams
//		params.alpha = 0.92f;
//		window.setGravity(Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL);
//		window.setAttributes(params);// 设置生效
//
//		LayoutInflater fac = LayoutInflater.from(context);
//		View more_pop_menu = fac.inflate(R.layout.dialog_cls_detail, null);
//		dialog.setCanceledOnTouchOutside(true);
//		dialog.setContentView(more_pop_menu);
//		params.height = ViewGroup.LayoutParams.WRAP_CONTENT;
//		params.width = getActivity().getWindowManager().getDefaultDisplay()
//				.getWidth() - 30;
//		dialog.show();
//
//		new MyGeneralDetailOnClick(dialog, mMap, more_pop_menu, position);
//	}

	class MyGeneralDetailOnClick implements View.OnClickListener {

		private View mianView;
		private Dialog dialog;
		private int setType = 0;
		private LinearLayout detail_close;
		private LinearLayout detail;
		private LinearLayout after;
		private LinearLayout setting;
		private Map<String, String> mMap;
		private int closeType = 0;
		private TextView detail_after;
		private TextView detail_more;
		private LinearLayout detail_zhuanfa;
		private TextView timebefore_tv;
		// 更多
		private LinearLayout more_openstate;
		private TextView more_zhuanfasjb;
		private TextView more_zhuanfawx;
		private TextView more_setdaiban;
		private TextView more_shitingmusic;
		private TextView more_delete;
		private TextView more_openstate_tv;
		// 详情
		private TextView detail_date;
		private TextView detail_content;
		private TextView detail_year_date;
		private TextView detail_time_date;
		private TextView detail_tv_shun;
		private LinearLayout detail_edit_ll;
		// 推后
		private TextView after_autopostone;// 自动顺延
		private TextView after_onehour;// 推后一小时
		private TextView after_oneday;// 推后一天
		private TextView after_oneweek;// 推后一周
		private TextView after_onemonth;// 推后一个月
		private TextView after_nextweekfirstday;// 推到下周一
		private TextView after_today;// 推到今天
		private TextView after_tommrow;// 推到明天
		private View after_today_view, after_tommrow_view, after_onehour_view,
				after_oneday_view, after_oneweek_view, after_onemonth_view,
				after_nextweekfirstday_view;

		private TextView detail_important;
		String today, tomorrow;
		Calendar calendar = Calendar.getInstance();
		int position;

		@SuppressLint("NewApi")
		public MyGeneralDetailOnClick(Dialog dialog, Map<String, String> mMap,
				View view, int position) {
			this.position = position;
			this.dialog = dialog;
			this.mMap = mMap;
			this.mianView = view;
			calendar.setTime(new Date());
			today = DateUtil.formatDate(calendar.getTime());
			calendar.set(Calendar.DAY_OF_MONTH,
					calendar.get(Calendar.DAY_OF_MONTH) + 1);
			tomorrow = DateUtil.formatDate(calendar.getTime());
			String key = mMap.get(ScheduleTable.schDate);
			String timeKey = mMap.get(ScheduleTable.schTime);
			detail_close = (LinearLayout) view.findViewById(R.id.detail_close);
			detail_close.setOnClickListener(this);
			timebefore_tv = (TextView) view.findViewById(R.id.timebefore_tv);
			detail = (LinearLayout) view.findViewById(R.id.detail);
			after = (LinearLayout) view.findViewById(R.id.after);
			setting = (LinearLayout) view.findViewById(R.id.setting);
			detail_after = (TextView) view.findViewById(R.id.detail_after);
			detail_after.setOnClickListener(this);
			detail_more = (TextView) view.findViewById(R.id.detail_more);
			detail_more.setOnClickListener(this);
			// detail_edit = (LinearLayout) view.findViewById(R.id.detail_edit);
			// detail_edit.setOnClickListener(this);
			// 更多
			more_openstate = (LinearLayout) view
					.findViewById(R.id.more_openstate);
			more_openstate_tv = (TextView) view
					.findViewById(R.id.more_openstate_tv);
			more_zhuanfasjb = (TextView) view
					.findViewById(R.id.more_zhuanfasjb);
			more_zhuanfawx = (TextView) view.findViewById(R.id.more_zhuanfawx);
			more_setdaiban = (TextView) view.findViewById(R.id.more_setdaiban);
			more_shitingmusic = (TextView) view
					.findViewById(R.id.more_shitingmusic);
			more_delete = (TextView) view.findViewById(R.id.more_delete);
			more_openstate.setOnClickListener(this);
			more_zhuanfasjb.setOnClickListener(this);
			more_zhuanfawx.setOnClickListener(this);
			more_setdaiban.setOnClickListener(this);
			more_shitingmusic.setOnClickListener(this);
			more_delete.setOnClickListener(this);
			// 详情
			detail_zhuanfa = (LinearLayout) view
					.findViewById(R.id.detail_zhuanfa);
			detail_zhuanfa.setOnClickListener(this);
			detail_edit_ll = (LinearLayout) view
					.findViewById(R.id.detail_edit_ll);
			detail_edit_ll.setOnClickListener(this);
			detail_date = (TextView) view.findViewById(R.id.detail_date);
			detail_year_date = (TextView) view
					.findViewById(R.id.detail_year_date);
			detail_tv_shun = (TextView) view.findViewById(R.id.detail_tv_shun);
			String colorState = ""
					+ context.getResources().getColor(R.color.mingtian_color);
			// 顺延
			String sequence = "<font color='" + colorState + "'>"
					+ context.getString(R.string.adapter_shun) + "</font>";
			int shunBackKuang = R.drawable.tv_kuang_aftertime;
			detail_tv_shun.setText(Html.fromHtml(sequence));
			detail_tv_shun.setBackgroundResource(shunBackKuang);
			if (today.equals(key)) {
				detail_year_date.setText("今天");
			} else if (tomorrow.equals(key)) {
				detail_year_date.setText("明天");
			} else {
				detail_year_date.setText(key);
			}
			detail_time_date = (TextView) view
					.findViewById(R.id.detail_time_date);
			detail_time_date.setText(mMap.get(ScheduleTable.schTime));
			timebefore_tv = (TextView) view.findViewById(R.id.timebefore_tv);
			detail_content = (TextView) view.findViewById(R.id.detail_content);
			detail_content.setText(mMap.get(ScheduleTable.schContent));
			if ("1".equals(mMap.get(ScheduleTable.schIsPostpone))) {
				detail_tv_shun.setVisibility(View.VISIBLE);
			} else {
				detail_tv_shun.setVisibility(View.GONE);
			}

			// 推后
			after_autopostone = (TextView) view
					.findViewById(R.id.after_autopostone);
			after_autopostone.setOnClickListener(this);
			after_onehour = (TextView) view.findViewById(R.id.after_onehour);
			after_onehour.setOnClickListener(this);
			after_oneday = (TextView) view.findViewById(R.id.after_oneday);
			after_oneday.setOnClickListener(this);
			after_oneweek = (TextView) view.findViewById(R.id.after_oneweek);
			after_oneweek.setOnClickListener(this);
			after_onemonth = (TextView) view.findViewById(R.id.after_onemonth);
			after_onemonth.setOnClickListener(this);
			after_nextweekfirstday = (TextView) view
					.findViewById(R.id.after_nextweekfirstday);
			after_nextweekfirstday.setOnClickListener(this);
			after_today = (TextView) view.findViewById(R.id.after_today);
			after_today.setOnClickListener(this);
			after_tommrow = (TextView) view.findViewById(R.id.after_tommrow);
			after_tommrow.setOnClickListener(this);
			after_today_view = view.findViewById(R.id.after_today_view);
			after_tommrow_view = view.findViewById(R.id.after_tommrow_view);
			after_onehour_view = view.findViewById(R.id.after_onehour_view);
			after_oneday_view = view.findViewById(R.id.after_oneday_view);
			after_oneweek_view = view.findViewById(R.id.after_oneweek_view);
			after_onemonth_view = view.findViewById(R.id.after_onemonth_view);
			after_nextweekfirstday_view = view
					.findViewById(R.id.after_nextweekfirstday_view);

			detail_date.setText(CharacterUtil.getWeekOfDate(getActivity(),
					DateUtil.parseDate(key)));
			Date dateStr = DateUtil.parseDateTime(key + " " + timeKey);
			Date dateToday = DateUtil.parseDateTime(DateUtil
					.formatDateTime(new Date()));
			long betweem = (long) (dateToday.getTime() - dateStr.getTime()) / 1000;
			long day = betweem / (24 * 3600);
			long hour = betweem % (24 * 3600) / 3600;
			long min = betweem % 3600 / 60;

			if (today.equals(key)) {// 今天
				if (DateUtil.parseDateTime(DateUtil.formatDateTime(new Date()))
						.after(DateUtil.parseDateTime(DateUtil
								.formatDateTime(dateStr)))) {
					if (Math.abs(hour) >= 1) {
						timebefore_tv.setText(Math.abs(hour) + "小时前");
					} else {
						timebefore_tv.setText(Math.abs(min) + "分钟前");
					}
				} else {
					if (Math.abs(hour) >= 1) {
						timebefore_tv.setText(Math.abs(hour) + "小时后");
					} else {
						timebefore_tv.setText(Math.abs(min) + "分钟后");
					}
				}
			} else if (tomorrow.equals(key)) {// 明天
				if (Math.abs(day) >= 1) {
					timebefore_tv.setText(Math.abs(day) + "天后");
				} else {
					timebefore_tv.setText(Math.abs(hour) + "小时后");

				}
			} else {
				timebefore_tv.setText(Math.abs(day) + 1 + "天后");
			}
			detail_important = (TextView) view
					.findViewById(R.id.detail_important);
			detail_important.setOnClickListener(this);
			// detail_edit.setVisibility(View.VISIBLE);
			if ("0".equals(mMap.get(ScheduleTable.schIsPostpone)))
				after_autopostone.setText("自动顺延");
			else
				after_autopostone.setText("取消顺延");
			Drawable jieshu = getResources().getDrawable(
					R.mipmap.btn_quxiaozhongyao);
			Drawable weijieshu = getResources().getDrawable(
					R.mipmap.btn_zhongyao);
			// 调用setCompoundDrawables时，必须调用Drawable.setBounds()方法,否则图片不显示
			jieshu.setBounds(0, 0, jieshu.getMinimumWidth(),
					jieshu.getMinimumHeight());
			weijieshu.setBounds(0, 0, jieshu.getMinimumWidth(),
					jieshu.getMinimumHeight());
			if ("0".equals(mMap.get(ScheduleTable.schIsImportant))) {
				detail_important.setText("设为重要");
				detail_important.setCompoundDrawables(null, jieshu, null, null);
			} else {
				detail_important.setText("取消重要");
				detail_important.setCompoundDrawables(null, weijieshu, null,
						null);
			}
			int colortype = Integer.parseInt(mMap
					.get(ScheduleTable.schColorType));
			String colorname = application.QueryTagNameData(colortype).get(
					"ctgText");
			more_openstate_tv.setText("(" + colorname + ")");
			if (DateUtil.parseDate(key).getTime() <= DateUtil.parseDate(
					DateUtil.formatDate(new Date())).getTime()) {
				if (inWeekUtils.isInWeek(key)) {
					after_autopostone.setVisibility(View.VISIBLE);
					after_onehour.setVisibility(View.GONE);
					after_oneday.setVisibility(View.GONE);
					after_oneweek.setVisibility(View.VISIBLE);
					after_onemonth.setVisibility(View.VISIBLE);
					after_nextweekfirstday.setVisibility(View.VISIBLE);
					after_today.setVisibility(View.VISIBLE);
					after_tommrow.setVisibility(View.VISIBLE);
					after_today_view.setVisibility(View.VISIBLE);
					after_tommrow_view.setVisibility(View.VISIBLE);
					after_onehour_view.setVisibility(View.GONE);
					after_oneday_view.setVisibility(View.GONE);
					after_oneweek_view.setVisibility(View.VISIBLE);
					after_onemonth_view.setVisibility(View.VISIBLE);
					after_nextweekfirstday_view.setVisibility(View.VISIBLE);
				} else {
					if (inWeekUtils.isInMonth(key)) {
						after_autopostone.setVisibility(View.VISIBLE);
						after_onehour.setVisibility(View.GONE);
						after_oneday.setVisibility(View.GONE);
						after_oneweek.setVisibility(View.GONE);
						after_onemonth.setVisibility(View.VISIBLE);
						after_nextweekfirstday.setVisibility(View.VISIBLE);
						after_today.setVisibility(View.VISIBLE);
						after_tommrow.setVisibility(View.VISIBLE);
						after_today_view.setVisibility(View.VISIBLE);
						after_tommrow_view.setVisibility(View.VISIBLE);
						after_onehour_view.setVisibility(View.GONE);
						after_oneday_view.setVisibility(View.GONE);
						after_oneweek_view.setVisibility(View.GONE);
						after_onemonth_view.setVisibility(View.VISIBLE);
						after_nextweekfirstday_view.setVisibility(View.VISIBLE);
					} else {
						after_autopostone.setVisibility(View.VISIBLE);
						after_onehour.setVisibility(View.GONE);
						after_oneday.setVisibility(View.GONE);
						after_oneweek.setVisibility(View.GONE);
						after_onemonth.setVisibility(View.GONE);
						after_nextweekfirstday.setVisibility(View.VISIBLE);
						after_today.setVisibility(View.VISIBLE);
						after_tommrow.setVisibility(View.VISIBLE);
						after_today_view.setVisibility(View.VISIBLE);
						after_tommrow_view.setVisibility(View.VISIBLE);
						after_onehour_view.setVisibility(View.GONE);
						after_oneday_view.setVisibility(View.GONE);
						after_oneweek_view.setVisibility(View.GONE);
						after_onemonth_view.setVisibility(View.GONE);
						after_nextweekfirstday_view.setVisibility(View.VISIBLE);
					}
				}
			} else {
				boolean fag = inWeekUtils.getNextWeek(context, key);
				if (fag) {
					after_autopostone.setVisibility(View.VISIBLE);
					after_onehour.setVisibility(View.VISIBLE);
					after_oneday.setVisibility(View.VISIBLE);
					after_oneweek.setVisibility(View.VISIBLE);
					after_onemonth.setVisibility(View.VISIBLE);
					after_nextweekfirstday.setVisibility(View.VISIBLE);
					after_today.setVisibility(View.GONE);
					after_tommrow.setVisibility(View.GONE);
					after_today_view.setVisibility(View.GONE);
					after_tommrow_view.setVisibility(View.GONE);
					after_onehour_view.setVisibility(View.VISIBLE);
					after_oneday_view.setVisibility(View.VISIBLE);
					after_oneweek_view.setVisibility(View.VISIBLE);
					after_onemonth_view.setVisibility(View.VISIBLE);
					after_nextweekfirstday_view.setVisibility(View.VISIBLE);
				} else {
					after_autopostone.setVisibility(View.VISIBLE);
					after_onehour.setVisibility(View.VISIBLE);
					after_oneday.setVisibility(View.VISIBLE);
					after_oneweek.setVisibility(View.VISIBLE);
					after_onemonth.setVisibility(View.VISIBLE);
					after_nextweekfirstday.setVisibility(View.GONE);
					after_today.setVisibility(View.GONE);
					after_tommrow.setVisibility(View.GONE);
					after_today_view.setVisibility(View.GONE);
					after_tommrow_view.setVisibility(View.GONE);
					after_onehour_view.setVisibility(View.VISIBLE);
					after_oneday_view.setVisibility(View.VISIBLE);
					after_oneweek_view.setVisibility(View.VISIBLE);
					after_onemonth_view.setVisibility(View.VISIBLE);
					after_nextweekfirstday_view.setVisibility(View.GONE);
				}
			}
			// 设置菜单判断
			if (setType == 1) {
				after.setVisibility(View.GONE);
				detail.setVisibility(View.GONE);
				setting.setVisibility(View.VISIBLE);
			}
		}

		@Override
		public void onClick(View v) {
			Animation translateIn0 = new TranslateAnimation(
					-mianView.getWidth(), 0, 0, 0);
			Animation translateIn1 = new TranslateAnimation(
					mianView.getWidth(), 0, 0, 0);
			translateIn0.setDuration(400);
			translateIn1.setDuration(400);
			App app = App.getDBcApplication();
			String key = mMap.get(ScheduleTable.schDate);
			String timeKey = mMap.get(ScheduleTable.schTime);
			Date dateStr;
			long datetime = 0;
			int id = Integer.parseInt(mMap.get(ScheduleTable.schID));
			String date;
			dateStr = DateUtil.parseDateTime(key + " " + timeKey);
			datetime = dateStr.getTime();
			Intent intent = new Intent();
			MySchBean mySchBean = new MySchBean();
			mySchBean.schID = mMap.get(ScheduleTable.schID);
			mySchBean.schContent = mMap.get(ScheduleTable.schContent);
			mySchBean.schDate = mMap.get(ScheduleTable.schDate);
			mySchBean.schTime = mMap.get(ScheduleTable.schTime);
			mySchBean.schIsAlarm = mMap.get(ScheduleTable.schIsAlarm);
			mySchBean.schBeforeTime = mMap.get(ScheduleTable.schBeforeTime);
			mySchBean.schDisplayTime = mMap.get(ScheduleTable.schDisplayTime);
			mySchBean.schIsPostpone = mMap.get(ScheduleTable.schIsPostpone);
			mySchBean.schIsImportant = mMap.get(ScheduleTable.schIsImportant);
			mySchBean.schColorType = mMap.get(ScheduleTable.schColorType);
			mySchBean.schIsEnd = mMap.get(ScheduleTable.schIsEnd);
			mySchBean.schCreateTime = mMap.get(ScheduleTable.schCreateTime);
			mySchBean.schTags = mMap.get(ScheduleTable.schTags);
			mySchBean.schSourceType = mMap.get(ScheduleTable.schSourceType);
			mySchBean.schSourceDesc = mMap.get(ScheduleTable.schSourceDesc);
			mySchBean.schSourceDescSpare = mMap
					.get(ScheduleTable.schSourceDescSpare);
			mySchBean.schRepeatID = mMap.get(ScheduleTable.schRepeatID);
			mySchBean.schRepeatDate = mMap.get(ScheduleTable.schRepeatDate);
			mySchBean.schUpdateTime = mMap.get(ScheduleTable.schUpdateTime);
			mySchBean.schUpdateState = mMap.get(ScheduleTable.schUpdateState);
			mySchBean.schOpenState = mMap.get(ScheduleTable.schOpenState);
			mySchBean.schRepeatLink = mMap.get(ScheduleTable.schRepeatLink);
			mySchBean.schRingDesc = mMap.get(ScheduleTable.schRingDesc);
			mySchBean.schRingCode = mMap.get(ScheduleTable.schRingCode);
			mySchBean.schcRecommendName = mMap
					.get(ScheduleTable.schcRecommendName);
			mySchBean.schRead = mMap.get(ScheduleTable.schRead);
			Map<String, String> map = App.getDBcApplication().QueryStateData(
					Integer.parseInt(mMap.get(ScheduleTable.schRepeatID)));
			switch (v.getId()) {
			case R.id.detail_close:
				if (closeType != 0) {
					hint();
					// detail_edit.setVisibility(View.VISIBLE);
					detail.setVisibility(View.VISIBLE);
					detail.startAnimation(translateIn0);
					closeType = 0;
				} else {
					dialog.dismiss();
				}
				break;
			case R.id.detail_edit_ll:
				String i = mMap.get(ScheduleTable.schID);
				intent.putExtra("id", i);
				intent.putExtra("content", detail_content.getText().toString());
				intent.putExtra("year", key);
				intent.putExtra("time", detail_time_date.getText().toString());
				intent.putExtra("week", detail_date.getText().toString());
				intent.putExtra("tixing", timebefore_tv.getText().toString());
				intent.putExtra("beforetime",
						mMap.get(ScheduleTable.schBeforeTime));
				intent.putExtra("openState",
						mMap.get(ScheduleTable.schOpenState));
				intent.putExtra("lingshengname",
						mMap.get(ScheduleTable.schRingDesc));
				intent.putExtra("ringcode", mMap.get(ScheduleTable.schRingCode));
				intent.putExtra("recommendID",
						mMap.get(ScheduleTable.schcRecommendId));
				intent.putExtra("recommendname",
						mMap.get(ScheduleTable.schcRecommendName));
				intent.putExtra("repid", mMap.get(ScheduleTable.schRepeatID));
				intent.putExtra("repdate",
						mMap.get(ScheduleTable.schRepeatDate));
				intent.putExtra("replink",
						mMap.get(ScheduleTable.schRepeatLink));
				intent.putExtra("aid", mMap.get(ScheduleTable.schAID));
				intent.putExtra("friendID", mMap.get(ScheduleTable.schFriendID));
				intent.putExtra("schIsAlarm",
						mMap.get(ScheduleTable.schIsAlarm));
				intent.putExtra("postpone",
						mMap.get(ScheduleTable.schIsPostpone));
				intent.putExtra("important",
						mMap.get(ScheduleTable.schIsImportant));
				intent.putExtra("coclor", mMap.get(ScheduleTable.schColorType));
				intent.putExtra("isEnd", mMap.get(ScheduleTable.schIsEnd));
				intent.putExtra("displaytime",
						mMap.get(ScheduleTable.schDisplayTime));
				startActivity(intent.setClass(getActivity(),
						AddEverydayDetailTaskActivity.class));
				dialog.dismiss();
				break;
			case R.id.detail_after:
				hint();
				after.setVisibility(View.VISIBLE);
				detail_zhuanfa.setVisibility(View.GONE);
				after.startAnimation(translateIn1);
				break;
			case R.id.detail_more:
				hint();
				detail_zhuanfa.setVisibility(View.GONE);
				setting.setVisibility(View.VISIBLE);
				setting.startAnimation(translateIn1);
				break;

			// ---------------更多子项事件--------------------
			case R.id.more_openstate:// 谁可以看
				try {
					app.updateSchReadData(
							Integer.parseInt(mMap.get(ScheduleTable.schID)), 0);
					App.getDBcApplication().updateSchRepeatLinkData(
							Integer.parseInt(mMap.get(ScheduleTable.schID)), 0);
					if ("".equals(mMap.get(ScheduleTable.schRepeatDate))) {

					} else {
						if (map != null) {
							String repdate = mMap
									.get(ScheduleTable.schRepeatDate);
							String lastdate = StringUtils.getIsStringEqulesNull(map
									.get(CLRepeatTable.repDateOne));
							String nextdate = StringUtils.getIsStringEqulesNull(map
									.get(CLRepeatTable.repDateTwo));
							repeatSetChildEndUtils.setParentState(Integer.parseInt(mMap
									.get(ScheduleTable.schRepeatID)),repdate,nextdate,lastdate,map);
						}
					}
					updateFocusStateSch(mMap, ScheduleTable.schFocusState);
					// loadData();
					adapter.notifyDataSetChanged();
					intent.putExtra("statename", more_openstate_tv.getText()
							.toString());
					intent.putExtra("id", mMap.get(ScheduleTable.schID));
					startActivity(intent.setClass(context,
							MyStateActivity.class));
				} catch (Exception e) {
					e.printStackTrace();
				}
				dialog.dismiss();
				break;
			case R.id.detail_zhuanfa:
				intent.putExtra("bean", mySchBean);
				if (!mySchBean.schRepeatID.equals("0")){
					startActivity(intent
							.setClass(context, SchZhuanFaActivity.class));
				}else {
					startActivity(intent
							.setClass(context, NewSchZhuanFaActivity.class));
				}
				dialog.dismiss();
				break;
			case R.id.more_zhuanfasjb:// 转发时间表好友
				intent.putExtra("bean", mySchBean);
				startActivity(intent
						.setClass(context, SchZhuanFaActivity.class));
				dialog.dismiss();
				break;
			case R.id.more_zhuanfawx:// 转发微信好友
				ShareSDK.initSDK(getActivity());
				OnekeyShare oks = new OnekeyShare();
				// 关闭sso授权
				oks.disableSSOWhenAuthorize();
				// 分享时Notification的图标和文字 2.5.9以后的版本不调用此方法
				// oks.setNotification(R.drawable.ic_launcher,
				// getString(R.string.app_name));
				// title标题，印象笔记、邮箱、信息、微信、人人网和QQ空间使用
				// oks.setTitle(title);
				// titleUrl是标题的网络链接，仅在人人网和QQ空间使用
				// oks.setTitleUrl(path);
				// text是分享文本，所有平台都需要这个字段
				oks.setText(mySchBean.schDate + "  " + mySchBean.schTime + "  "
						+ mySchBean.schContent);
				// imagePath是图片的本地路径，Linked-In以外的平台都支持此参数
				// oks.setImagePath(ParameterUtil.userHeadImg+imageUrl+"&imageType=2&imageSizeType=3");//
				// 确保SDcard下面存在此张图片
				// url仅在微信（包括好友和朋友圈）中使用
				// oks.setUrl(path);
				// oks.setImageUrl(URLConstants.图片+imageUrl+"&imageType=2&imageSizeType=3");
				// comment是我对这条分享的评论，仅在人人网和QQ空间使用
				// oks.setComment("我是测试评论文本");
				// site是分享此内容的网站名称，仅在QQ空间使用
				// oks.setSite(getString(R.string.app_name));
				// siteUrl是分享此内容的网站地址，仅在QQ空间使用
				// oks.setSiteUrl("http://sharesdk.cn");

				// 启动分享GUI
				oks.show(getActivity());
				dialog.dismiss();
				break;
			case R.id.more_setdaiban:// 设为待办 今天+全天+顺延
				try {
					app.updateScheduleUnTaskData(mySchBean.schID);
					app.updateSchReadData(
							Integer.parseInt(mMap.get(ScheduleTable.schID)), 0);
					App.getDBcApplication().updateSchRepeatLinkData(
							Integer.parseInt(mMap.get(ScheduleTable.schID)), 0);
					app.updateUnTaskClockDate(
							Integer.parseInt(mMap.get(ScheduleTable.schID)),
							ringdesc, ringcode);
					if ("".equals(mMap.get(ScheduleTable.schRepeatDate))
							|| "0".equals(mMap.get(ScheduleTable.schRepeatLink))) {

					} else {
						if (map != null) {
							String repdate = mMap
									.get(ScheduleTable.schRepeatDate);
							String lastdate = StringUtils.getIsStringEqulesNull(map
									.get(CLRepeatTable.repDateOne));
							String nextdate = StringUtils.getIsStringEqulesNull(map
									.get(CLRepeatTable.repDateTwo));
							repeatSetChildEndUtils.setParentState(Integer.parseInt(mMap
									.get(ScheduleTable.schRepeatID)),repdate,nextdate,lastdate,map);
						}
					}
					updateFocusStateSch(mMap, ScheduleTable.schFocusState);
					loadData();
					QueryAlarmData.writeAlarm(getActivity()
							.getApplicationContext());

					adapter.notifyDataSetChanged();
					RefreshMyData();
				} catch (Exception e) {
					e.printStackTrace();
				}
				dialog.dismiss();
				break;
			case R.id.more_shitingmusic:// 试听铃声
				final MediaPlayer mediaPlayer = new MediaPlayer();

				try {
					AssetFileDescriptor fileDescriptor = getActivity()
							.getAssets().openFd(
									mMap.get(ScheduleTable.schRingCode)
											+ ".mp3");
					mediaPlayer.setDataSource(
							fileDescriptor.getFileDescriptor(),
							fileDescriptor.getStartOffset(),
							fileDescriptor.getLength());
					mediaPlayer.prepare();
					mediaPlayer.start();
				} catch (IllegalArgumentException e) {
					e.printStackTrace();
				} catch (SecurityException e) {
					e.printStackTrace();
				} catch (IllegalStateException e) {
					e.printStackTrace();
				} catch (IOException e) {
					e.printStackTrace();
				}
				dialog.dismiss();
				break;
			case R.id.more_delete:// 删除
				try {
					alertDeleteDialog(mMap, 0, position);
				} catch (Exception e) {
					e.printStackTrace();
				}
				dialog.dismiss();
				break;
			// --------------推后子项--------------------
			case R.id.after_autopostone:
				updateSchedule(mMap, ScheduleTable.schIsPostpone,
						ScheduleTable.schUpdateState);
				updateSchClock(mMap, LocateAllNoticeTable.postpone);
				updateFocusStateSch(mMap, ScheduleTable.schFocusState);
				calendar.setTime(DateUtil.parseDate(mMap
						.get(ScheduleTable.schDate)));
				if (DateUtil.parseDate(mMap.get(ScheduleTable.schDate)).before(
						DateUtil.parseDate(DateUtil.formatDate(new Date())))) {
					calendar.set(Calendar.DAY_OF_MONTH,
							calendar.get(Calendar.DAY_OF_MONTH) + 1);
					date = DateUtil.formatDate(calendar.getTime());
					app.updateScheduleDateData(id, date,
							mMap.get(ScheduleTable.schTime));
				}

				app.updateSchReadData(
						Integer.parseInt(mMap.get(ScheduleTable.schID)), 0);
				App.getDBcApplication().updateSchRepeatLinkData(
						Integer.parseInt(mMap.get(ScheduleTable.schID)), 0);
				if ("".equals(mMap.get(ScheduleTable.schRepeatDate))
						|| "0".equals(mMap.get(ScheduleTable.schRepeatLink))) {

				} else {
					if (map != null) {
						String repdate = mMap
								.get(ScheduleTable.schRepeatDate);
						String lastdate = StringUtils.getIsStringEqulesNull(map
								.get(CLRepeatTable.repDateOne));
						String nextdate = StringUtils.getIsStringEqulesNull(map
								.get(CLRepeatTable.repDateTwo));
						repeatSetChildEndUtils.setParentState(Integer.parseInt(mMap
								.get(ScheduleTable.schRepeatID)),repdate,nextdate,lastdate,map);
					}
				}
				loadData();
				QueryAlarmData
						.writeAlarm(getActivity().getApplicationContext());

				adapter.notifyDataSetChanged();
				RefreshMyData();
				dialog.dismiss();
				break;
			case R.id.after_onehour:
				try {
					updateFocusStateSch(mMap, ScheduleTable.schFocusState);
					date = inWeekUtils.AfterOneHours(key,
							mMap.get(ScheduleTable.schTime));
					app.updateScheduleDateData(id, date.substring(0, 10)
							.toString(), date.substring(11, 16).toString());
					app.updateSchReadData(
							Integer.parseInt(mMap.get(ScheduleTable.schID)), 0);
					App.getDBcApplication().updateSchRepeatLinkData(
							Integer.parseInt(mMap.get(ScheduleTable.schID)), 0);
					if ("".equals(mMap.get(ScheduleTable.schRepeatDate))
							|| "0".equals(mMap.get(ScheduleTable.schRepeatLink))) {

					} else {
						if (map != null) {
							String repdate = mMap
									.get(ScheduleTable.schRepeatDate);
							String lastdate = StringUtils.getIsStringEqulesNull(map
									.get(CLRepeatTable.repDateOne));
							String nextdate = StringUtils.getIsStringEqulesNull(map
									.get(CLRepeatTable.repDateTwo));
							repeatSetChildEndUtils.setParentState(Integer.parseInt(mMap
									.get(ScheduleTable.schRepeatID)),repdate,nextdate,lastdate,map);
						}
					}
					loadData();
					adapter.notifyDataSetChanged();
					QueryAlarmData.writeAlarm(getActivity()
							.getApplicationContext());

					RefreshMyData();
				} catch (Exception e) {
					e.printStackTrace();
				}
				dialog.dismiss();
				break;
			case R.id.after_oneday:
				try {
					updateFocusStateSch(mMap, ScheduleTable.schFocusState);
					date = inWeekUtils.AfterOneDay(key);
					app.updateScheduleDateData(id, date,
							mMap.get(ScheduleTable.schTime));
					app.updateSchReadData(
							Integer.parseInt(mMap.get(ScheduleTable.schID)), 0);
					App.getDBcApplication().updateSchRepeatLinkData(
							Integer.parseInt(mMap.get(ScheduleTable.schID)), 0);
					if ("".equals(mMap.get(ScheduleTable.schRepeatDate))
							|| "0".equals(mMap.get(ScheduleTable.schRepeatLink))) {

					} else {
						if (map != null) {
							String repdate = mMap
									.get(ScheduleTable.schRepeatDate);
							String lastdate = StringUtils.getIsStringEqulesNull(map
									.get(CLRepeatTable.repDateOne));
							String nextdate = StringUtils.getIsStringEqulesNull(map
									.get(CLRepeatTable.repDateTwo));
							repeatSetChildEndUtils.setParentState(Integer.parseInt(mMap
									.get(ScheduleTable.schRepeatID)),repdate,nextdate,lastdate,map);
						}
					}
					loadData();
					adapter.notifyDataSetChanged();
					QueryAlarmData.writeAlarm(getActivity()
							.getApplicationContext());

					RefreshMyData();
				} catch (Exception e) {
					e.printStackTrace();
				}
				dialog.dismiss();
				break;
			case R.id.after_oneweek:
				try {
					updateFocusStateSch(mMap, ScheduleTable.schFocusState);
					date = inWeekUtils.AfterOneWeek(key);
					app.updateScheduleDateData(id, date,
							mMap.get(ScheduleTable.schTime));
					app.updateSchReadData(
							Integer.parseInt(mMap.get(ScheduleTable.schID)), 0);
					App.getDBcApplication().updateSchRepeatLinkData(
							Integer.parseInt(mMap.get(ScheduleTable.schID)), 0);
					if ("".equals(mMap.get(ScheduleTable.schRepeatDate))
							|| "0".equals(mMap.get(ScheduleTable.schRepeatLink))) {

					} else {
						if (map != null) {
							String repdate = mMap
									.get(ScheduleTable.schRepeatDate);
							String lastdate = StringUtils.getIsStringEqulesNull(map
									.get(CLRepeatTable.repDateOne));
							String nextdate = StringUtils.getIsStringEqulesNull(map
									.get(CLRepeatTable.repDateTwo));
							repeatSetChildEndUtils.setParentState(Integer.parseInt(mMap
									.get(ScheduleTable.schRepeatID)),repdate,nextdate,lastdate,map);
						}
					}
					loadData();
					adapter.notifyDataSetChanged();
					QueryAlarmData.writeAlarm(getActivity()
							.getApplicationContext());

					RefreshMyData();
				} catch (Exception e) {
					e.printStackTrace();
				}
				dialog.dismiss();
				break;
			case R.id.after_onemonth:// 推后一个月
				try {
					updateFocusStateSch(mMap, ScheduleTable.schFocusState);
					date = inWeekUtils.AfterOneMonth(key);
					app.updateScheduleDateData(id, date,
							mMap.get(ScheduleTable.schTime));
					app.updateSchReadData(
							Integer.parseInt(mMap.get(ScheduleTable.schID)), 0);
					App.getDBcApplication().updateSchRepeatLinkData(
							Integer.parseInt(mMap.get(ScheduleTable.schID)), 0);
					if ("".equals(mMap.get(ScheduleTable.schRepeatDate))
							|| "0".equals(mMap.get(ScheduleTable.schRepeatLink))) {

					} else {
						if (map != null) {
							String repdate = mMap
									.get(ScheduleTable.schRepeatDate);
							String lastdate = StringUtils.getIsStringEqulesNull(map
									.get(CLRepeatTable.repDateOne));
							String nextdate = StringUtils.getIsStringEqulesNull(map
									.get(CLRepeatTable.repDateTwo));
							repeatSetChildEndUtils.setParentState(Integer.parseInt(mMap
									.get(ScheduleTable.schRepeatID)),repdate,nextdate,lastdate,map);
						}
					}
					loadData();
					adapter.notifyDataSetChanged();
					QueryAlarmData.writeAlarm(getActivity()
							.getApplicationContext());

					RefreshMyData();
				} catch (Exception e) {
					e.printStackTrace();
				}
				dialog.dismiss();
				break;
			case R.id.after_nextweekfirstday:// 推后的下周一
				try {
					updateFocusStateSch(mMap, ScheduleTable.schFocusState);
					date = inWeekUtils.AfterNextWeekFirstDay(context, key);
					app.updateScheduleDateData(id, date,
							mMap.get(ScheduleTable.schTime));
					app.updateSchReadData(
							Integer.parseInt(mMap.get(ScheduleTable.schID)), 0);
					App.getDBcApplication().updateSchRepeatLinkData(
							Integer.parseInt(mMap.get(ScheduleTable.schID)), 0);
					if ("".equals(mMap.get(ScheduleTable.schRepeatDate))
							|| "0".equals(mMap.get(ScheduleTable.schRepeatLink))) {

					} else {
						if (map != null) {
							String repdate = mMap
									.get(ScheduleTable.schRepeatDate);
							String lastdate = StringUtils.getIsStringEqulesNull(map
									.get(CLRepeatTable.repDateOne));
							String nextdate = StringUtils.getIsStringEqulesNull(map
									.get(CLRepeatTable.repDateTwo));
							repeatSetChildEndUtils.setParentState(Integer.parseInt(mMap
									.get(ScheduleTable.schRepeatID)),repdate,nextdate,lastdate,map);
						}
					}
					loadData();
					adapter.notifyDataSetChanged();
					QueryAlarmData.writeAlarm(getActivity()
							.getApplicationContext());

					RefreshMyData();
				} catch (Exception e) {
					e.printStackTrace();
				}
				dialog.dismiss();
				break;
			case R.id.after_today:
				try {
					updateFocusStateSch(mMap, ScheduleTable.schFocusState);
					app.updateScheduleDateData(id, today,
							mMap.get(ScheduleTable.schTime));
					app.updateSchReadData(
							Integer.parseInt(mMap.get(ScheduleTable.schID)), 0);
					App.getDBcApplication().updateSchRepeatLinkData(
							Integer.parseInt(mMap.get(ScheduleTable.schID)), 0);
					if ("".equals(mMap.get(ScheduleTable.schRepeatDate))
							|| "0".equals(mMap.get(ScheduleTable.schRepeatLink))) {

					} else {
						if (map != null) {
							String repdate = mMap
									.get(ScheduleTable.schRepeatDate);
							String lastdate = StringUtils.getIsStringEqulesNull(map
									.get(CLRepeatTable.repDateOne));
							String nextdate = StringUtils.getIsStringEqulesNull(map
									.get(CLRepeatTable.repDateTwo));
							repeatSetChildEndUtils.setParentState(Integer.parseInt(mMap
									.get(ScheduleTable.schRepeatID)),repdate,nextdate,lastdate,map);
						}
					}
					loadData();
					adapter.notifyDataSetChanged();
					QueryAlarmData.writeAlarm(getActivity()
							.getApplicationContext());

					RefreshMyData();
				} catch (Exception e) {
					e.printStackTrace();
				}
				dialog.dismiss();
				break;
			case R.id.after_tommrow:
				try {
					updateFocusStateSch(mMap, ScheduleTable.schFocusState);
					app.updateScheduleDateData(id, tomorrow,
							mMap.get(ScheduleTable.schTime));
					app.updateSchReadData(
							Integer.parseInt(mMap.get(ScheduleTable.schID)), 0);
					App.getDBcApplication().updateSchRepeatLinkData(
							Integer.parseInt(mMap.get(ScheduleTable.schID)), 0);
					if ("".equals(mMap.get(ScheduleTable.schRepeatDate))
							|| "0".equals(mMap.get(ScheduleTable.schRepeatLink))) {

					} else {
						if (map != null) {
							String repdate = mMap
									.get(ScheduleTable.schRepeatDate);
							String lastdate = StringUtils.getIsStringEqulesNull(map
									.get(CLRepeatTable.repDateOne));
							String nextdate = StringUtils.getIsStringEqulesNull(map
									.get(CLRepeatTable.repDateTwo));
							repeatSetChildEndUtils.setParentState(Integer.parseInt(mMap
									.get(ScheduleTable.schRepeatID)),repdate,nextdate,lastdate,map);
						}
					}
					loadData();
					adapter.notifyDataSetChanged();
					QueryAlarmData.writeAlarm(getActivity()
							.getApplicationContext());

					RefreshMyData();
				} catch (Exception e) {
					e.printStackTrace();
				}
				dialog.dismiss();
				break;
			// --------------详情子项事件----------------

			case R.id.detail_important:
				try {
					updateFocusStateSch(mMap, ScheduleTable.schFocusState);
					app.updateSchReadData(
							Integer.parseInt(mMap.get(ScheduleTable.schID)), 0);
					app.updateSchRepeatLinkData(
							Integer.parseInt(mMap.get(ScheduleTable.schID)), 0);
					if (!"".equals(mMap.get(ScheduleTable.schRepeatDate))
							&& !"0".equals(mMap
									.get(ScheduleTable.schRepeatLink))) {
						if (map != null) {
							String repdate = mMap
									.get(ScheduleTable.schRepeatDate);
							String lastdate = StringUtils.getIsStringEqulesNull(map
									.get(CLRepeatTable.repDateOne));
							String nextdate = StringUtils.getIsStringEqulesNull(map
									.get(CLRepeatTable.repDateTwo));
							repeatSetChildEndUtils.setParentState(Integer.parseInt(mMap
									.get(ScheduleTable.schRepeatID)),repdate,nextdate,lastdate,map);
						}
						updateRepSchUpdate(mMap, ScheduleTable.schIsImportant,
								ScheduleTable.schUpdateState);
					} else {
						updateSchedule(mMap, ScheduleTable.schIsImportant,
								ScheduleTable.schUpdateState);
					}
					mList.remove(position);
					mMap.put(ScheduleTable.schRepeatLink, "0");
					mList.add(position, mMap);
					RefreshMyData();
					adapter.notifyDataSetChanged();
					important_listview.invalidate();
					if (DateUtil.parseDateTime(
							DateUtil.formatDateTime(new Date())).getTime() >= DateUtil
							.parseDateTime(
									mMap.get(ScheduleTable.schDate) + " "
											+ mMap.get(ScheduleTable.schTime))
							.getTime()) {
						QueryAlarmData.writeAlarm(getActivity()
								.getApplicationContext());

					}
				} catch (Exception e) {
					e.printStackTrace();
				}
				dialog.dismiss();
				break;
			}
		}

		private void hint() {
			closeType = 1;
			after.setVisibility(View.GONE);
			setting.setVisibility(View.GONE);
			detail.setVisibility(View.GONE);
		}
	}

	// private void deleteDialog(final String id, final Map<String, String>
	// mMap,
	// final int type) {
	// final AlertDialog builder = new AlertDialog.Builder(context).create();
	// builder.show();
	// Window window = builder.getWindow();
	// android.view.WindowManager.LayoutParams params =
	// window.getAttributes();// 获取LayoutParams
	// params.alpha = 0.92f;
	// window.setAttributes(params);// 设置生效
	// window.setContentView(R.layout.dialog_alterdelete);
	// TextView delete_ok = (TextView) window.findViewById(R.id.delete_ok);
	// delete_ok.setOnClickListener(new View.OnClickListener() {
	//
	// @Override
	// public void onClick(View v) {
	// builder.cancel();
	// if (type == 0) {
	// String deleteId = id;
	// App dbContextExtended = App.getDBcApplication();
	// dbContextExtended.deleteScheduleData(deleteId);
	// mList.clear();
	// loadData();
	// adapter.notifyDataSetChanged();
	// }
	// }
	// });
	// TextView delete_canel = (TextView) window
	// .findViewById(R.id.delete_canel);
	// delete_canel.setOnClickListener(new View.OnClickListener() {
	//
	// @Override
	// public void onClick(View v) {
	// builder.cancel();
	// }
	// });
	// TextView delete_tv = (TextView) window.findViewById(R.id.delete_tv);
	// if (type == 0) {
	// delete_tv.setText("确定要删除此记事吗?");
	// } else {
	// delete_tv.setText("结束今天之前所有未结束的记事?");
	// }
	//
	// }
	private void updateRepSchUpdate(Map<String, String> mMap, String key,
			String key1) {
		try {
			String value = "0";
			Map<String, String> upMap = new HashMap<String, String>();
			important_listview.hiddenRight();
			if ("0".equals(mMap.get(key)))
				value = "1";
			else
				value = "0";
			upMap.put(key, value);
			if (!"0".equals(upMap.get(ScheduleTable.schAID))) {
				upMap.put(key1, "1");
			} else {
				upMap.put(key1, "1");
			}
			App.getDBcApplication().updateScheduleData(upMap,
					"where schID=" + mMap.get("schID"));
			mMap.put(key, value);
		} catch (NumberFormatException e) {
			e.printStackTrace();
		}
	}

	private void updateFocusStateSch(Map<String, String> mMap, String key) {
		try {
			Map<String, String> upMap = new HashMap<String, String>();
			upMap.put(key, "1");
			App.getDBcApplication().updateSchFocusState(upMap,
					"where schID=" + mMap.get("schID"));
		} catch (NumberFormatException e) {
			e.printStackTrace();
		}
	}

	private void updateSchedule(Map<String, String> mMap, String key,
			String key1) {
		String value = "0";
		Map<String, String> upMap = new HashMap<String, String>();
		important_listview.hiddenRight();
		if ("0".equals(mMap.get(key)))
			value = "1";
		else
			value = "0";
		upMap.put(key, value);
		upMap.put(key1, "2");
		App.getDBcApplication().updateScheduleData(upMap,
				"where schID=" + mMap.get("schID"));
		mMap.put(key, value);
	}

	private void updateScheduleIsEnd(Map<String, String> mMap, String key,
			String key1) {
		try {
			if ("1".equals(mMap.get(ScheduleTable.schRepeatLink))
					|| "3".equals(mMap.get(ScheduleTable.schRepeatLink))) {
				repeatSetChildEndUtils.setParentStateIsEnd(mMap);
			}
			String value = "0";
			Map<String, String> upMap = new HashMap<String, String>();
			important_listview.hiddenRight();
			if ("0".equals(mMap.get(key)))
				value = "1";
			else
				value = "0";
			upMap.put(key, value);
			if ("1".equals(mMap.get(ScheduleTable.schRepeatLink))
					|| "3".equals(mMap.get(ScheduleTable.schRepeatLink))) {
				upMap.put(key1, "0");
			} else {
				upMap.put(key1, "2");
			}
			App.getDBcApplication().updateScheduleData(upMap,
					"where schID=" + mMap.get("schID"));
			mMap.put(key, value);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	private void updateSchClock(Map<String, String> mMap, String key) {
		try {
			String value = "0";
			String key1 = "";
			Map<String, String> upMap = new HashMap<String, String>();
			if (key.equals("isEnd")) {
				key1 = "schIsEnd";
			} else if (key.equals("postpone")) {
				key1 = "schIsPostpone";
			}
			if ("1".equals(mMap.get(key1)))
				value = "1";
			else
				value = "0";
			upMap.put(key, value);
			App.getDBcApplication().updateSchIsEnd(upMap,
					"where schID=" + mMap.get("schID"));
		} catch (NumberFormatException e) {
			e.printStackTrace();
		}
	}

}
